我有一棵左树.它的结构是这样的
MainCategory Category1 Subcategory1 Subcategory2 Category2 Subcategory3 Subcategory4 Subcategory5 Category3 . .. etc like that
如果用户单击MainCategory / Category / Subcategory中的任何一个,我需要禁用/阻止重复/多次单击同一链接,直到结果出现.如何使用jquery做到这一点?
解决方法:
如果您使用jQuery 1.7,则可以使用off()和on()功能
例:
var foo = function () {
// code to handle some kind of event
};
// ... now foo will be called when paragraphs are clicked ...
$("body").on("click", "p", foo);
// ... foo will no longer be called.
$("body").off("click", "p", foo);
例:
var foo = function () {
// code to handle some kind of event
};
// ... now foo will be called when paragraphs are clicked ...
$("body p").bind("click", foo);
// ... foo will no longer be called.
$("body p").unbind("click");