jQuery中事件的解除问题

来源:互联网 发布:萝卜网络 编辑:程序博客网 时间:2024/06/06 08:39

如果在开发中出现了页面和文件重复加载严重导致网页运行缓慢的问题时,要注意已经添加的事件是否解除了绑定。

使用unbind()来解除绑定,例如:

//左侧tab切换$("html").unbind().on("click", ".left-nav > li", function(event){var index=$(this).index();var dateTime = new Date().getTime();var tempData = {quoteType: "e",orderBy: 2,quoteDate: dateTime,detailType: "",page: 1,rows: 5};$.ajax({type: "POST",url: global.context+"/web/front/quoteFollow/showChange",contentType: "application/json;charset=UTF-8",dataType: "html",async: false,data: JSON.stringify(tempData),success: function(msg){$("html").html(msg);event.stopPropagation();}});$(".left-nav > li").removeClass("active");$(".left-nav > li").eq(index).addClass("active");$(".table-block").addClass("hide").removeClass("show");$(".table-block").eq(index).addClass("show").removeClass("hide");});
over


0 0
原创粉丝点击