3
我只是想禁用用户点击某个条件的元素的能力,然后为其他条件重新绑定它。以下是我正在使用的一些代码:jquery解除绑定和绑定
$('#navigation a').bind('click',function(e){
var $this = $(this);
var prev = current;
current = $this.parent().index() + 1;
if (current == 1){
$("#navigation a:eq(1)").unbind("click"); // remove the click for element
}
if (current >= 2){
$("#navigation a:eq(1)").bind("click"); // this doesn't work, but i want re-bind the click here.
} }
我需要做些什么来完成这项工作?
什么错误你得到了吗? – 2011-01-05 04:56:43
如何在函数中返回false而不是绑定/解除绑定?另外,一个命名函数会使事情变得更容易。 – 2011-01-05 05:00:30
查看http://api.jquery.com/live/,我想你可以做preventDefault()而不是解除绑定 – 2011-01-05 05:01:00