用jquery添加綁定事件 添加多少次 點擊的時候就觸發多少次 如果想解決這個問題 就在點擊函數里先用 $(對象).off("click") 取消上一次的點擊事件
上碼:
$("#pdfId").click(function () { $.ajax({ //url: "/SwFrontData/GetAttachmentData/" + $("#wdId").val(), url:url2, type: "post", dataType: "json", success: function (data) { console.log("1"); console.log(data); for (var i = 0; i < data.length; i++) { if (data[i].ContentType == 0) { WordHideOrShow(data[i].ContentPath); } } }, error: function (err) { } }); $("#pdfId").off("click"); //取消每次的點擊 });