[英]activate button after another button click in javascript
我有三个按钮,单击一个按钮后,第二个必须访问单击,然后单击第三个。当我单击第三个按钮时,它不起作用
<input type="button" value="button" id="one" onclick="show()" action="">
<input type="button" value="button" id="two" onclick="show1()">
<input type="action" value="button" id="three">
<script>
function show{
}
</script>
最初使用禁用第二个和第三个按钮:
<input type="button" value="button" id="two" onclick="show1()" disabled="disabled"/>
<input type="action" value="button" id="three" disabled="disabled"/>
并使用此代码:
function show()
{
document.getElementById('two').removeAttribute('disabled');
}
// And Same For Second Button Click
function show1()
{
document.getElementById('three').removeAttribute('disabled');
}
jQuery在这里会更好:
$('#one').click(function () { // on a click on the button with id 'one'
$('#two').trigger('click');// trigger the click on second, and go on
}
使用此方法,可以使用特定元素上的事件来触发其他元素上的事件!
<script>
function show(){
$('#button1').attr('disabled',false);
$('#button2').attr('disabled',false);
}
function show1(){
$('#button2').attr('disabled',false);
}
</script>
您可以使用Jquery将事件绑定到点击。 然后执行您想要的操作:
$('#ButtonID').bind('click',function(){
$('#ButtonID2').show();
//or
$('#ButtonID1').removeAttr('disabled');//if you want it be shown but not enabled
});
这是用于禁用按钮:
$('#ButtonID').attr('disabled','disabled');
你在找这个吗
$("input").click(function(){
$("input").attr('disabled','disabled');
$(this).next().removeAttr('disabled');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.