1

使用后如何删除“取消绑定”?我需要重新启用点击事件。在我的职能之下。

1.此功能是禁用打印链接

function edit(){
$("#ENQUIRY_VIEWMETER a.print").addClass('ui-state-disabled').unbind("click");
}

2.使链接可点击。

function reset(){
$("#ENQUIRY_VIEWMETER a.print").removeClass('ui-state-disabled').bind("click");
}

还有其他方法可以让我再次点击链接吗?

4

2 回答 2

2

通过使用新的 Jquery 1.7On()off()方法,您可以通过以下方式实现此目的...有关更多详细信息,请阅读使用示例

离开():

$('#ENQUIRY_VIEWMETER a.print').off("click");

或者

('#ENQUIRY_VIEWMETER').off('click', 'a.print');

在():

$('#ENQUIRY_VIEWMETER a.print').on('click', handleClick);
于 2012-07-02T05:13:54.533 回答
1

将事件代码缓存在变量中并使用事件命名空间。也使用on()sincebind()已被弃用。

var foo = function () { ... }

$el.on('click.foo', foo) // Bind event `foo` on click

$el.off('click.foo') // Unbind `foo` events attached to `click`
$el.off('.foo') // Unbind all `foo` events

$el.on('click.foo', foo) // Bind again
于 2012-07-02T05:08:34.350 回答