Hi,
My dom looks like:
<div class="blah">
<a href=""><img .. ></a>
<strong>blah blah</strong>
<a href=""><img /></a>
</div>
How can I get the value of the strong when I know the class is "blah" ?
$(".blah").find("strong")
doesn't work?
Hi,
My dom looks like:
<div class="blah">
<a href=""><img .. ></a>
<strong>blah blah</strong>
<a href=""><img /></a>
</div>
How can I get the value of the strong when I know the class is "blah" ?
$(".blah").find("strong")
doesn't work?
Try this:
$(".blah").find("strong").html();
$(".blah").find("strong") will only return the jQuery object, not it's contents.
var value = $('.blah strong').html();
Simpler than pim's answer but works in manly the same way. It finds all descendants of .blah that are strong tags and gives back the html content of the first one.
Try this
<script type="text/javascript">
$(document).ready(function() {
alert($(".blah > strong").text());
});
</script>
<div class="blah">
<a href="#">
<img src="#" /></a> <strong>blah blah</strong>
</div>