More than one css class clickable in javascript

前端 未结 3 1116
小鲜肉
小鲜肉 2021-01-27 05:17

How can I do so that even \"toggle_cart\" is clickable in the same way as \"clickerHeader\" but retains its hover effect (see arrow)?

please see http://jsfiddle.net/real

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-27 06:07

    In the CSS add:

    .eventMenu:hover .no-js .contentHolderHeader {
        display: block;
    }
    

    Also add a display: none to div.eventMenu .contentHolderHeader.

    Replace the JS with:

    $('.eventMenu > ul').toggleClass('no-js js');
    $(".toggle_cart").click(function(e){
        $(".contentHolderHeader").slideToggle();
        e.stopPropagation();
    });
    $(".eventMenu").click(function(e){
        e.stopPropagation();
    });
    $(document).click(function(){ 
        $(".contentHolderHeader").slideUp();
    });
    

    Remove the inner ul in the HTML.

    Tested with/without JS: http://jsfiddle.net/vuF9n/2/

提交回复
热议问题