How do I dynamically enable/disable links with jQuery?

后端 未结 6 759
执笔经年
执笔经年 2020-12-01 05:08

I have some links displayed on a page. I would like to enable/disable them based on other events on the page. Is there a way to do this with jQuery?

6条回答
  •  执笔经年
    2020-12-01 05:53

    $(document).delegate('.links', 'click', function () {
      if ([your condition is true]) {
        return false;
      }
    })
    

    delegation is better than handlers, because you can call them before the dom is loaded

提交回复
热议问题