Keep parent with children open when linking to new page

杀马特。学长 韩版系。学妹 提交于 2019-11-29 12:34:36

You may notice that after you click an item in the menu, that menu item will load with the class "active". You can then target this menu item via active and show the item.

Here is the code:

if($('.active.parent > ul').length > 0)
{
    $('.active.parent > ul').show();
}

The first line just checks that there is an active element, otherwise we might get a script error. Within the bracers the code simply shows the element. Give this a go and let me know how you get on.

Also, it's a good idea to utilize your developer toolbar (F12) in cases like this, so you can monitor the DOM and spot things like the active class.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!