我有一个这样的按钮:
<input id="Button" type="button" value="+" style="background-color:grey" onclick="Me();"/>
当我需要时,我如何禁用和启用它?我已经尝试了禁用=“禁用”,但启用它回来是一个问题。我试着把它设置回false,但那没有启用它。
我有一个这样的按钮:
<input id="Button" type="button" value="+" style="background-color:grey" onclick="Me();"/>
当我需要时,我如何禁用和启用它?我已经尝试了禁用=“禁用”,但启用它回来是一个问题。我试着把它设置回false,但那没有启用它。
当前回答
这肯定会奏效。
禁用按钮
$('#btn_id').button('disable');
启用按钮
$('#btn_id').button('enable');
其他回答
这肯定会奏效。
禁用按钮
$('#btn_id').button('disable');
启用按钮
$('#btn_id').button('enable');
$(".btncancel").button({ disabled: true });
这里'btncancel'是按钮的类名。
使用jQuery,你可以在一行中完成
//Enable
$('#Button').prop('disabled', false)
//Disable
$('#Button').prop('disabled', true)
坚持使用php…
为什么不只是允许按钮出现一旦上述条件得到满足。
<?
if (whatever == something) {
$display = '<input id="Button" type="button" value="+" style="background-color:grey" onclick="Me();"/>';
return $display;
}
?>
使用JavaScript禁用/启用html输入按钮:
(以及与裁判反应。取代“elementRef。如果不使用React,元素选择current)
elementRef.current.setAttribute('disabled', 'disabled');
启用:
elementRef.current.removeAttribute('disabled');