Good morning I'm doing a form in HTML with JS and I have a field to enter an image by URL my idea is to enter with an input type
{ input type="url" placeholder="Enter URL of the image" > }
To show the image you should only capture the value entered in your input
once it has been changed, that is achieved with the event change
, then you must assign that value to src
of a label img
, something like this:
$("#url").change(function(){
var url = $(this).val();
$("#imagen").html('<img src="'+ url +'" alt="imagen">')
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="url" placeholder="Ingrese URL de la imagen" id="url">
<div id="imagen"></div>
I hope you serve, greetings!