Disable a link in Bootstrap

前端 未结 6 1664
挽巷
挽巷 2021-02-03 16:40

The first example didn\'t work. I need to have always a list to disable links? Or what is wrong with my first demo?

Disabl         


        
6条回答
  •  轮回少年
    2021-02-03 17:23

    I just created my own version using CSS. As I need to disabled, then when document is ready use jQuery to make active. So that way a user cannot click on a button until after the document is ready. So i can substitute with AJAX instead. The way I came up with, was to add a class to the anchor tag itself and remove the class when document is ready. Could re-purpose this for your needs.

    CSS:

    a.disabled{
        pointer-events: none;
        cursor: default;
    }
    

    HTML:

    Link Text
    

    JS:

    $(function(){
        $('a.disabled').on('click',function(event){
            event.preventDefault();
        }).removeClass('disabled');
    });
    

提交回复
热议问题