How do I dynamically enable/disable links with jQuery?

后端 未结 6 767
执笔经年
执笔经年 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:51

    When I am giving functions to the buttons by jquery, I like to do this:

    indice = '';
    
    $('myLink').live('click',function() {
        if (indice !== 'value1'){
    
            // your code
        }
    
        indice = 'value1';
        return indice;
    
    });
    

    with this, you get the function just the first time you press de button. Now you just have to set indice different of value1 to your link works again

提交回复
热议问题