Only apply code to divs within a specific div?
I have a page where the markup looks like this:
<div id="maindiv">
<div id="post1"> content </div>
</div>
<div id="subdiv">
<div id="post3"> content </div>
<div id="post5"> content</div>
</div>
I'm trying to pull *only* the ids of the posts within the subdiv container. The code pops up an alert box for post1, post3, and post5, but I only want it to return post3 and post5...
-
$j('div[id^="post-"]').each(function() {
alert(this.id);
});
/* Tried this */
#j("#subdiv").each(function() {
$j('div[id^="post-"]').each(function() {
alert(this.id);
});
});
But, it still return all three ids...[/code]