伙计们,我有一个创建动态按钮的 ajax,每个按钮的 id 上都有一个计数器。我试图选择每个按钮并向它们添加一个类。
var html;
$.ajax({
type:'POST',
url:'add_subject.php',
dataType:'json',
data:{'func_numbr':'6'},
success:function (data){
var counter_sub = 0 ;
$.each(data, function(i, item) {
if(data[i].subjct_statu == "0"){
$('#inactivate['+counter_sub+']').addClass("inactiveButton");
}
html = "<tr>";
html += "<td><lable>Subject: </label><input type='text' name='subject["+counter_sub+"]' rel='"+data[i].subj_id+"' value='"+data[i].subj_name+"'></td>";
html += "<td><input type='button' id='activate["+counter_sub+"]' name='active' class='button active ' value='Apply' > ";
html += "<input type='button' id='inactivate["+counter_sub+"]' name='active' class='button inactive' value='Remove from list'></td>";
html += "</tr>";
$('#curr-4thhigh-tble').append(html);
counter_sub = counter_sub +1;
});
}
});
但是我正在做的事情不起作用,我想有什么问题。请帮助 tnx 进阶