【发布时间】:2012-05-13 06:55:59
【问题描述】:
我最终试图找到页面上的所有图像标签并打印出没有 alt 标签的那些。
现在我有这个:
var str = '<img id="img1" /><img id="img2" /><img id="img3" /><img id="img4" alt="ASDF" title="" /><img id="img5" alt="" /><img id="img6" title="" />';
var imagesWithoutAlt = $( str ).filter( 'img:not([alt])' );
var newString = new String( $( imagesWithoutAlt ).clone().html());
$(document.body).append($('<textarea rows="6" cols="40"/>').text( newString );
但这无法输出任何内容。帮忙?
【问题讨论】:
-
您需要将 imagesWithoutAlt 克隆包装在一个元素中并获取该元素的 html。
-
好的。我是 jQuery 新手,我该怎么做?
标签: jquery html image html-parsing