Disabled dropdown menu items using twitter bootstrap

前端 未结 8 1089
挽巷
挽巷 2021-02-03 20:16

I use markup to display a dropdown menu using Twitter Bootstrap.

8条回答
  •  孤独总比滥情好
    2021-02-03 20:44

    You can attach a custom disabled class to your menu link a tag that you want to disable and simply remove the default action by using preventDefault and targetting that class, like so:

    $(".disabled-link").click(function(event) {
      event.preventDefault();
    });
    

    Then you can style all events from the .disabled-link with a grey backdrop or any style you like;

    CSS

    a.disabled-link,
    a.disabled-link:visited ,
    a.disabled-link:active,
    a.disabled-link:hover {
        background-color:#d9d9d9 !important;
        color:#aaa !important;
    }
    

    Demo

提交回复
热议问题