开发者

WordPress & jQuery submenus

开发者 https://www.devze.com 2023-03-23 04:56 出处:网络
I\'m working on a clients site and it has a sidebar menu, which contains product categories and products as submenus for the product categories. The thing is, that I made it toggle so that if you clic

I'm working on a clients site and it has a sidebar menu, which contains product categories and products as submenus for the product categories. The thing is, that I made it toggle so that if you click on the product category, it would open up the sub menus and if clicked again, it closes. Now, if I click on the product that is on the sub menu, i get to the products page, but I need it to show the submenu in an open state as well.

So far the code is...

    $("#sidebar ul li a").click(function(e){
        if( $(this).parent().children('ul').length > 0 ){
            e.preventDefault(); //prevent the link from being followed
            $(this).parent().find('ul').toggle('100');
        }
    });

Now, i want it to have something like ...

    if( $开发者_如何学Go("#sidebar .current_page_item") (<< has two ULS, meaning it's a submenu >>)
        $(this). (<< some code to make the submenu display:block >>)
    }

I however have no idea what-so-ever how to do this, any help would be appreciated.


This was linked by someone else on another question much like yours(page loads slow FYI)

(Naturally you can apply your own look to that script, it is really just an example of how to make a menu down my default using jquery.).

In a way your question is a bit of a duplicate, but that isn't a big deal.

Any way, you can toggle sub menu's being down by default if you look at that other question asked a while back, the problem in your case is that you only want the menu to be down by default on one page. So you will need to either figure out how to apply the action via jquery, and maybe some php within wordpress to only one page. Or an alternative option is to just have two menu scripts, one being down by default that is only on that page and another one that makes the menu's behave as they do on all of the other pages. Somebody who has a better jquery understanding then me can probably help more with that portion of the development, but I hope this helps.

0

精彩评论

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