Reputation: 5802
I'm using this code for showing image inside any tag:
var imgs = $(this).find("p").attr("rel");
$('.hLeft img').attr("src", imgs);
Markup:
<div class="hLeft">
<h2></h2>
<a href="" class="mn">
</a>
<img src="" />
</div>
But when I insert <img>
inside a, my script not working.
$('.mn img').attr("src", imgs);
Markup:
<div class="hLeft">
<h2></h2>
<a href="" class="mn">
<img src="" />
</a>
</div>
Why the $('.mn img').attr("src", imgs);
not working with a tag?
Upvotes: 0
Views: 780
Reputation: 2381
the img is over written by this line:
$("a", $hleft).html(mansetText);
Upvotes: 1
Reputation: 7870
I think it deals with the css properties of class mn
. div
are displayed as block by default which is not the case for a
. Try to add display:block;
in the mn
class to see the result.
Upvotes: 0