Jquery : How Turn Link From Textarea To Image In Div?
How can I turn the URL link from textarea to do image in
? Example:
Solution 1:
You can use the .attr() function to set the src and the .text() to get the url as follows:
$( document ).ready( function(){
let url = $('#sample').text();
if(url)
$('#myImg').attr('src', url);
} );<scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><textareaid="sample">https://tvorbawebu.net/eshopserver/uploads/thumbnail/Pentair-Led-Pool-Lights.jpg</textarea><divclass="viewimage"><imgalt=""id="myImg"src=""></div>
Post a Comment for "Jquery : How Turn Link From Textarea To Image In Div?"