[英]RemoveAttr doesn't remove disabled
<input type="checkbox" name="checking">j'accepte les conditions
<input type="submit" value="Valider" id="valide" disabled/>
<script>
$(document).ready(function(){
if((input=$("input:checkbox[name=checking]").is(":checked"))){
$("#valide").prop('disabled',true);
}
});
</script>
Hi, i want enable button (valide) when i checked checkbox嗨,当我选中复选框时,我想要启用按钮(valide)
So...respond to a click on the checkbox setting disabled
to false
if the checkbox is ticked.所以...如果勾选了复选框,则响应单击disabled
为false
的复选框设置。 In this example, I'm assuming you also want to set disabled
to true
if the checkbox is unticked again:在此示例中,我假设您还希望在再次取消选中该复选框时将disabled
设置为true
:
if((input=$("input:checkbox[name=checking]").is(":checked"))){
$("#valide").prop('disabled',true); // <== You might want to make this depend on the initial state of the checkbox
}
input.on("click", function() {
$("#valide").prop('disabled', !this.checked);
});
you must add listener to check box for call function every time when user check or uncheck it每次用户选中或取消选中它时,您都必须将侦听器添加到调用函数的复选框中
try this sloution :)试试这个 slotion :)
<input type="checkbox" onclick="check()" name="checking">j'accepte les conditions
<input type="submit" value="Valider" id="valide" disabled/>
function check(){
if($('input[name=checking]').is(":checked")){
$("#valide").prop('disabled',false);
}else{
$("#valide").prop('disabled',true);
}
}
please be sure to add javascript code after your html code请务必在您的 html 代码后添加 javascript 代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.