开发者

jQuery selector: this.parent, is there such a thing?

I have a lot of div boxes with nested div .titles, with a button inside. Is there a way in jQuery to select the parent of the button?

Something like:

$("#button").click(function(){       
       $("this.parent").css({'border-bottom' : 'none'});
       }); 
开发者_运维百科

Or am I going to have to rename all of my title classes to unique classes?


Give this a whirl (inside an event handler for that button):

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


Try this :

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

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


jQuery.parent()

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜