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();
精彩评论