jQuery : how turn link from textarea to image in div?
How can I turn the URL link from textarea to do image in &lt;div&gt; ?
Example:
&lt;textarea id=&quot;sample&quot;&gt;https://tvorbawebu.net/eshopserver/uploads/thumbnail/Pentair-Led-Pool-Lights.jp...
https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196
Stack Overflow
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); } );

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <textarea id="sample">https://tvorbawebu.net/eshopserver/uploads/thumbnail/Pentair-Led-Pool-Lights.jpg</textarea> <div class="viewimage"><img alt="" id="myImg" src=""></div>

Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid …

Asking for help, clarification, or responding to other answers.

Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.