2014-02-11 55 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/