[英]How to select all URLs inside a text area using jQuery?
I can select all img link as well as PDF link using the following: 我可以使用以下选项选择所有img链接以及PDF链接:
$("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 DOM
element inside a textarea, so the above code can't work 你不能在textarea中附加一个DOM
元素,所以上面的代码不能工作
the selector itself $("#mytxt:contains('.jpg')")
is perfectly working when a .jpg
occurence is found : see fiddle http://jsfiddle.net/Mqu66/ 当发现.jpg
时,选择器本身$("#mytxt:contains('.jpg')")
完全正常工作:请参阅小提琴http://jsfiddle.net/Mqu66/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.