我有很多div嵌套div .title
s,里面有一个按钮。有没有在jQuery中选择按钮的父级的方法?jQuery选择器:this.parent,是否有这样的事情?
喜欢的东西:
$("#button").click(function(){
$("this.parent").css({'border-bottom' : 'none'});
});
还是我有我所有的标题类重命名为不同类别的?
我有很多div嵌套div .title
s,里面有一个按钮。有没有在jQuery中选择按钮的父级的方法?jQuery选择器:this.parent,是否有这样的事情?
喜欢的东西:
$("#button").click(function(){
$("this.parent").css({'border-bottom' : 'none'});
});
还是我有我所有的标题类重命名为不同类别的?
给这个一抡(在事件处理中该按钮):
$(this).parent().css({'border-bottom' : 'none'});
@GlenCrawford你有额外的“在那里 – ant 2010-06-02 11:33:03
@ c0mrade:bug =中和 – GlenCrawford 2010-06-02 11:35:04
@GlenCrawford肯定:) – ant 2010-06-02 11:36:40
试试这个:
$("#button").click(function(){
$(this).parent().css({'border-bottom' : 'none'});
});
或$(this).parent("div").css({'border-bottom' : 'none'});
$(function(){
$("div.title a").click(function(){
$(this).parent().css("background-color", "red");
return false;
});
});
不是选择器,但一个 方法。选择器总是在树上向上,而不是向下。 – Guffa 2010-06-02 11:35:28
方法是我的意思..我发誓...谢谢:) – Kyle 2010-06-02 11:49:37