js 防止重复追加,我每次点添加有了就不让他再次添加

$("#adddata").die('click');
$("#adddata").live('click',function(){
//获取当前打开状态选项卡的索引
var tabSelectedIndex = thisdiv.find('.tabs').find('.tabs-selected').index();
//获取选中节点的ID
var IDstring = onCheck(tabSelectedIndex);
$.ajax({
type: "POST",
url:'http://localhost/zongp/index.php/WholesaleOrders/Getcouponinfo',
dataType: "html",
data: {"id":IDstring},
success: function(data){
eval('myjson=' + data + ';');
var JsonStr = '';
PageOne(myjson['goods'],myjson['TableTitle'],0,'goodstable',0,0,JsonStr,0,0,1,0,options.pagelistnum);
}
});

在回调函数里添加点击事件解绑语句:

$("#adddata").unbind('click').prop('disabled', true);
温馨提示:答案为网友推荐,仅供参考