0
我正在尝试更改单击事件中的某个div元素。 我的问题是我该如何选择这个元素? 例如,
$("#a").live('click', function(){
$('.b').html('text') // I want to change class 'b' inside $(this).parent() and not all 'b' classes
});
我正在尝试更改单击事件中的某个div元素。 我的问题是我该如何选择这个元素? 例如,
$("#a").live('click', function(){
$('.b').html('text') // I want to change class 'b' inside $(this).parent() and not all 'b' classes
});
这可能做的伎俩:
$(this).find('.b').html('text');
你可以用一个以上的方式做到这一点!
$('#el').on('click', function(){
$(this).parent().find('.something').text('new text');
});
$('#el').on('click', function(){
$(this).next('.something').text('new text'); //or closest
});
希望这可以帮助!
你去那里:http://api.jquery.com/find/。 –