Find all link in a div element and disable them all

前端 未结 4 1969
夕颜
夕颜 2021-02-15 16:15

Assume that I have some HTML elements like these :

Click me
相关标签:
4条回答
  • I would rely less on jQuery as it might be disabled by the user, so if you want a CSS solution, you can do it like

    #content_div {
       pointer-events: none;
       cursor: default;
    }
    

    Demo

    Edit: To be precise, use this declaration #content_div a

    0 讨论(0)
  • 2021-02-15 16:40

    Try this:

     $("#content_div a").click(function(e) {
       e.preventDefault();
     });
    
    0 讨论(0)
  • 2021-02-15 16:48

    There are two ways here:

    1) $('#content a').css({"pointer-events":"none"});

    2) $('#content a').click(function(e){ e.preventDefault(); });

    0 讨论(0)
  • 2021-02-15 16:52
    $("#content_div a").css({"color":"#888888", cursor: "default"}).click(function(e){
       e.preventDefault();
    });
    

    Working Example http://jsfiddle.net/P4Fqq/

    0 讨论(0)
提交回复
热议问题