2010-06-02 73 views
0

我有很多div嵌套div .title s,里面有一个按钮。有没有在jQuery中选择按钮的父级的方法?jQuery选择器:this.parent,是否有这样的事情?

喜欢的东西:

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

还是我有我所有的标题类重命名为不同类别的?

+2

不是选择器,但一个 方法。选择器总是在树上向上,而不是向下。 – Guffa 2010-06-02 11:35:28

+0

方法是我的意思..我发誓...谢谢:) – Kyle 2010-06-02 11:49:37

回答

6

给这个一抡(在事件处理中该按钮):

$(this).parent().css({'border-bottom' : 'none'}); 
+0

@GlenCrawford你有额外的“在那里 – ant 2010-06-02 11:33:03

+0

@ c0mrade:bug =中和 – GlenCrawford 2010-06-02 11:35:04

+0

@GlenCrawford肯定:) – ant 2010-06-02 11:36:40

6

试试这个:

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

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

1

jQuery.parent()

$(function(){ 
    $("div.title a").click(function(){ 
    $(this).parent().css("background-color", "red"); 
    return false; 
    }); 
}); 
相关问题