jQuery选择器:this.parent,有这样的东西吗?

Kyl*_*yle 0 html css jquery

我有很多带有嵌套div .title的div框,里面有一个按钮.有没有办法在jQuery中选择按钮的父级?

就像是:

$("#button").click(function(){       
       $("this.parent").css({'border-bottom' : 'none'});
       }); 
Run Code Online (Sandbox Code Playgroud)

或者我是否必须将所有标题类重命名为独特的类?

ant*_*ant 6

试试这个 :

$("#button").click(function(){       
       $(this).parent().css({'border-bottom' : 'none'});
       });
Run Code Online (Sandbox Code Playgroud)

要么 $(this).parent("div").css({'border-bottom' : 'none'});


Gle*_*ord 6

给它一个旋转(在该按钮的事件处理程序内):

$(this).parent().css({'border-bottom' : 'none'});
Run Code Online (Sandbox Code Playgroud)