dimanche 22 février 2015

Javascript (or jquery) to get every image tag of a textarea value

So suppose I have a textarea with a value of this:



<p>..random content..</p>
<img src="myimage1.jpg" />
<p>..random content..</p>
<img src="myimage2.png" />
<p>..random content..</p>


I want to check every img tag occurences and store the src in an array. Something like this:



function img_find() {
var imgs = // the result of the checking of the textarea
var imgSrcs = [];

for (var i = 0; i < imgs.length; i++) {
imgSrcs.push(imgs[i].src);
}

return imgSrcs;
}


How do I achieve this?


Aucun commentaire:

Enregistrer un commentaire