相关疑难解决方法(0)

jquery - 禁用单击

我只想禁用用户在某些条件下单击元素的功能.以下是我正在使用的一些代码:

     $('#navigation a').bind('click',function(e){

    var $this   = $(this);
    var prev    = current;

    current = $this.parent().index() + 1; // store the position in current

    if (current == 1){
    $("#navigation a:eq(1)").unbind("click"); // i want to disable the ability to click this element if current is 1
    }
    if (current >= 2){
    $("#navigation a:eq(1)").bind("click"); // this is wrong, but I want to rebind the click if current is greater than 1.  
    }
Run Code Online (Sandbox Code Playgroud)

}

javascript jquery

44
推荐指数
4
解决办法
19万
查看次数

标签 统计

javascript ×1

jquery ×1