我有很多带有嵌套div .title的div框,里面有一个按钮.有没有办法在jQuery中选择按钮的父级?
就像是:
$("#button").click(function(){
$("this.parent").css({'border-bottom' : 'none'});
});
Run Code Online (Sandbox Code Playgroud)
或者我是否必须将所有标题类重命名为独特的类?
试试这个 :
$("#button").click(function(){
$(this).parent().css({'border-bottom' : 'none'});
});
Run Code Online (Sandbox Code Playgroud)
要么 $(this).parent("div").css({'border-bottom' : 'none'});
给它一个旋转(在该按钮的事件处理程序内):
$(this).parent().css({'border-bottom' : 'none'});
Run Code Online (Sandbox Code Playgroud)