jQuery选择器:this.parent,有这样的事情吗?

jQuery选择器:this.parent,有这样的事情吗?,jquery,html,css,Jquery,Html,Css,我有很多带有嵌套div.titles的div框,里面有一个按钮。jQuery中是否有方法选择按钮的父级 比如: $("#button").click(function(){ $("this.parent").css({'border-bottom' : 'none'}); }); 或者我必须将所有标题类重命名为唯一类吗?试试以下方法: $("#button").click(function(){ $(this).paren

我有很多带有嵌套div
.title
s的div框,里面有一个按钮。jQuery中是否有方法选择按钮的父级

比如:

$("#button").click(function(){       
       $("this.parent").css({'border-bottom' : 'none'});
       }); 
或者我必须将所有标题类重命名为唯一类吗?

试试以下方法:

$("#button").click(function(){       
       $(this).parent().css({'border-bottom' : 'none'});
       });
或者
$(this.parent(“div”).css({'border-bottom':'none'})

对其进行旋转(在该按钮的事件处理程序中):


@GlenCrawford你得到了额外的“谢谢,工作得很好!仍在学习jQuery,最好的方法就是这样做!@Kyle Sevenoaks打断一条腿,+1 GlenCrawford:)有一天我会回答一个jQuery问题:不是选择器,而是方法。选择器总是在树中向上,而不是向下。方法就是我的意思……我发誓……谢谢:)
$(this).parent().css({'border-bottom' : 'none'});
$(function(){
  $("div.title a").click(function(){
    $(this).parent().css("background-color", "red");
    return false;
  });
});