Reputation: 1754
This is a pretty common issue, but I can't figure it out. Let me post my code first:
<div class="myDeskContentRate">
<span class='myDeskContentStar'><img src='star.png'></span>
<div class='myDeskContentRateCount'><span class='starCount'>1</span></div>
</div>
And my jQuery:
$('.myDeskContentStar').click(function(){
$postId = $(this).attr('networkPostId');
$this = $(this);
$starCount = $this.next('.myDeskContentRateCount');
$.post('/includes/classes/handler.php?do=networkPostStar', { postId : $postId },
function(data){ $this.html(data); $starCount.nextUntil('.starCount').load('/includes/classes/handler.php?do=networkPostStarCount', { postId : $postId }); });
});
When a star is clicked it had to do the post and then the load, because it has to update the amounts of stars.
What my problem is, that I can't select the span class='starCount' inside of the div class='myDeskContentRateCount'.
I can get the class='myDeskContentRateCount' but that's not what I want. Is there a way for me to get the span class='starCount'?
Thanks in advance.
Upvotes: 0
Views: 155
Reputation: 7896
This will hopefully solve your problem:
$starCount = $this.next('.myDeskContentRateCount').find('.starCount');
Upvotes: 2
Reputation: 7536
$('div.myDeskContentRate > div.myDeskContentRateCount > span.starCount');
would select it. Other possibilities
$('div.myDeskContentRateCount').child('span.starCount');
$('div.myDeskContentRateCount').find('span.starCount');
Upvotes: 1