Reputation: 12512
I have the following code:
<div class="topLevel">
<span class="misc pointDown"></span>
<span class="misc"></span>
<span class="b">item</span>
</div>
When I click on the topLevel I need to replace "pointDown" with "pointUp". I think I have difficulty targeting the right element.
$(".topLevel").live('click', function() {
$(this).next("span").removeClass("pointDown").addClass("pointUp");
});
Upvotes: 2
Views: 5735
Reputation: 986
Don't assume the first item is your element - it's not the proper answer (if you ask me).
$('.topLevel').click(function() {
$(this).find('.misc.pointDown').removeClass('pointDown').addClass('pointUp');
}
Upvotes: 0
Reputation: 23253
$(".topLevel").live('click', function() {
$(this).find("span:eq(0)").removeClass("pointDown").addClass("pointUp");
});
Upvotes: 0
Reputation: 39182
$('.topLevel').live('click', function() {
$(this).children('span.pointDown').removeClass("pointDown").addClass("pointUp"); });
Upvotes: 0
Reputation: 146302
try this:
$(".topLevel").live('click', function() {
$(this).children('.misc').first()
.removeClass("pointDown").addClass("pointUp");
});
Upvotes: 4