0
我得到的邏輯有點問題就在這裏,我有一個激活和停用按鈕,這將使AJAX檢查,如果data[i].subj_status
或subject is = 0
的狀態解除按鈕會灰色和激活將變成藍色,這裏是代碼激活和關閉按鈕的顏色和禁用
var counter_sub = 0 ;
var html;
$.ajax({
type:'POST',
url:'add_subject.php',
dataType:'json',
data:{'func_numbr':'2'},
success:function (data){
var activator;
var disabler;
$.each(data, function(i, item) {
if(data[i].subj_status == "0"){
activator = "";
disabler = "";
}
else if(data[i].subj_status == "1"){
activator = "inactiveButton";
disabler = "disabled='disabled'";
}
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' name='active' class='button active "+activator+"' value='Active' "+disabler+"> ";
html += "<input type='button' id='inactivate' name='active' class='button inactive "+activator+"' value='Inactive'></td>";
html += "</tr>";
$('#curr-elem-tble').append(html);
counter_sub = counter_sub +1;
});
}
});
CSS:
.inactiveButton{
background:gray !important;
cursor:text;
}
但不幸的是,如果狀態等於1,他們都變成了藍色。 plsss幫助我們。先進的TNX。
IM應該使激活按鈕灰色如果狀態等於1,但不活動的是藍色的,使活性按鈕藍色和非活動轉義序列的使用是灰色,如果狀態爲0 – Aoi