jsp中显示一个废除按钮
从数据库中得到按钮的状态,判断按钮点击可否
<button class="btn btn-danger btn-xs" id="repealBtId_${comp.cotId}"
οnclick="repealCompType('${comp.cotId}');" type="button" ${comp.state==1? "":"disabled='disabled'"}>
<span class="glyphicon glyphicon-remove" id="spanid_${comp.cotId}">${comp.state==1?'作废':'已废除'}</span>
</button>
js 部分是为了实现点击后更新数据库里此按钮状态,并设置按钮为不可点击状态
function repealCompType(cotId) {
$.post("${baseUrl}compType/repealCompType", {
"cotId" : cotId
}, function(message) {
if (message == 1) {
$("#spanid_"+cotId).html('已废除');
$("#repealBtId_"+cotId).attr("disabled", true); //
alert("已废除!");
}
});
}