I can select all img link as well as PDF link using the following:
$("a[href$='pdf']").append('<img src="pdf.jpg" style="width:20px;height:20px;" > ');
$("a[href$='jpg']").append('<img src="jpg.jpg" style="width:20px;height:20px;" > ');
Now I have a text area
<textarea id="mytxt" name='post' style='width:100%;height:400px;margin-top:10px;border:solid thin #F1F1F1;line-height:20px;'>
</textarea>
$("#mytxt:contains('.jpg')").append('<img src="jpg.jpg" style="width:20px;height:20px;" > ');
The above selector won’t work.
you cannot append a
DOMelement inside a textarea, so the above code can’t workthe selector itself
$("#mytxt:contains('.jpg')")is perfectly working when a.jpgoccurence is found : see fiddle http://jsfiddle.net/Mqu66/