2014-02-11 51 views
-5

任何人都可以帮助我如何打开和关闭使用按钮。如何打开和关闭禁用按钮

enter image description here

当前代码:

<form> 
<input type="button" value="one" disabled /> 
<input type="button" value="two" /> 
</form> 
+0

'的document.getElementById( “1”)禁用= TRUE/FALSE' –

+0

看一看这个帖子: http://stackoverflow.com/questions/1594952/jQuery的禁用 - 启用 - 提交按钮 – mparkuk

回答

1

您将需要使用JavaScript。我的例子使用jQuery。引用的其他例子有点复杂,所以我为你做了这个。

// find the elements 
var $form = $('form'); 
var $buttons = $form.find('input[type=button]'); 

// event logic 
$buttons.click(function(e) { 
    $buttons.attr('disabled', false); 
    $(this).attr('disabled', true); 
}); 

将它放在页面上的onload或DomReady处理函数中。退房的小提琴,如果你想: http://jsfiddle.net/G5e48/