I have a multilevel menu. Each of level is a list with ul-tag. Each point of the menu is li-tag.
I want to slide down all of parent uls of the current point of the menu when loading the page.
Now I do the next:
var parents = selector.parents('ul');
parents.each(function(index, parent){
parent.slideDown();
});
But I get an error 'Uncaught TypeError: parent.slideDown is not a function'. And when I try to print a parent in console, I get the raw html. How can I get an access to the single parent inside each to make a slideDown? Or slide down all parents in any ways.
parent
is the reference to a DOM element, not a jQuery object. (That is simply how .each works.)
You need to wrap it in $()
before you can call jQuery methods on it.
parents.each(function(index, parent){
$(parent).slideDown();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.