我有一个左侧树形结构,它的结构如下:
主分类 分类1 子分类1 子分类2 分类2 子分类3 子分类4 子分类5 分类3 . ..等等
如果用户单击任何一个主分类/分类/子分类,我需要禁用/防止重复/多次单击相同的链接,直到结果出现。我该如何使用jquery实现这一点?
我有一个左侧树形结构,它的结构如下:
主分类 分类1 子分类1 子分类2 分类2 子分类3 子分类4 子分类5 分类3 . ..等等
如果用户单击任何一个主分类/分类/子分类,我需要禁用/防止重复/多次单击相同的链接,直到结果出现。我该如何使用jquery实现这一点?
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");
可以使用一个类来检查是否已经点击。
如果已经点击,则不执行,并在成功和失败时删除该类。
原型 -
$('.selector').click(function(){
if(!$(this).hasClass('someclass')){
$(this).addClass('someclass');
$.ajax({
url: "test.html",
success: function(){
$(this).removeClass("someclass");
},
error: function(){
$(this).removeClass("someclass");
}
});
}
})