Reputation: 8275
I have collection of "img" tags in "IFRAME".
i have to get the specified img element using src value
<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>
My current implementation is like this :
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;
}
}
});
}
it worked for me but it looped every img tag. It does not make sense. Anyone help me out how can find the img tag.
Like
`var element=$("srclink").contents().find("img");`
Upvotes: 0
Views: 92
Reputation: 430
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+"']"));
try this
Upvotes: 1
Reputation: 1785
you can try attribute equals selector [name=”value”] in jquery:
the_img_el = $("img[src='http://localhost:59023/ImageBrowser/GetImageData?path=download.jpg&companyId=50c2ca58-4036-4f0b-9a15-a3b000df6980']" )
Upvotes: 1