开发者

Better way to write this?

any better way to write this ?

$(this).parent().parent().find(" dd ul").toggle();


update..

I am trying to create a dropdown using the script h开发者_如何学Goere http://www.jankoatwarpspeed.com/post/2009/07/28/reinventing-drop-down-with-css-jquery.aspx

however the script works only for one instance of list and my code works good for multiple instances. Just curious if there is another better way to get parent of a parent in jQuery


You can use closest() method to find the parent dd element and go from there:

$(this).closest('dd').find('ul').toggle();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜