jQuery selector: this.parent, is there such a thing?
I have a lot of div boxes with nested div .title
s, with a button inside. Is there a way in jQuery to select the parent of the button?
Something like:
$("#button").click(function(){
$("this.parent").css({'border-bottom' : 'none'});
});
开发者_运维百科Or am I going to have to rename all of my title classes to unique classes?
Give this a whirl (inside an event handler for that button):
$(this).parent().css({'border-bottom' : 'none'});
Try this :
$("#button").click(function(){
$(this).parent().css({'border-bottom' : 'none'});
});
or $(this).parent("div").css({'border-bottom' : 'none'});
jQuery.parent()
$(function(){
$("div.title a").click(function(){
$(this).parent().css("background-color", "red");
return false;
});
});
精彩评论