我在“ IFRAME”中有“ img”标签的集合。
我必须使用src值获取指定的img元素
<iframe class="k-conent">
<html>
<body>
<img src="http://localhost:59023/ImageBrowser/GetImageData?path=download.jpg&companyId=50c2ca58-4036-4f0b-9a15-a3b000df6980" alt=""><img src="http://localhost:59023/ImageBrowser/GetImageData?path=itm_2013-04-23_09-56-06_1.jpg&companyId=50c2ca58-4036-4f0b-9a15-a3b000df6980" alt=""><br _moz_dirty="true">
</body>
</html>
</iframe>
我当前的实现是这样的:
var findalbelsrcvalue="http://localhost:59023/ImageBrowser/GetImageData?Path=download.jpg;companyId=50c2ca58-4036-4f0b-9a15-a3b000df6980"
var $content = $('.k-content').contents();
var $body = $content.find('body');
var $imagetag = $content.find('img');
if ($imagetag.length > 0) {
$imagetag.each(function() {
if($(this).attr("src")==findalbelsrcvalue){
var width = $('txtWidth').val();
var height = $('txtWidth').val();
switch ($("input[name=Alignment]:checked").val()) {
case "Left":
$(this).css('float', 'left');
case "Middle":
$(this).css('display', 'block');
$(this).css('margin-left', 'auto');
$(this).css('margin-right', 'auto');
case "Right":
$(this).css('float', 'right');
break;
default:
break;
}
}
});
}
它为我工作,但它循环了每个img标签。它没有任何意义。任何人都可以帮助我找到img标签。
喜欢
`var element=$("srclink").contents().find("img");`
var srcvalue="http://localhost:59023/ImageBrowser/GetImageData? Path=download.jpg;companyId=50c2ca58-4036-4f0b-9a15-a3b000df6980";
console.log($('.k-content').contents().find("body img[src='"+findalbelsrcvalue+"']"));
尝试这个
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句