admin管理员组

文章数量:1288076

I have three button are after clicking on one button,second has to access the click and then the third .when i click on the third button it should not work

<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>

I have three button are after clicking on one button,second has to access the click and then the third .when i click on the third button it should not work

<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>
Share Improve this question asked Mar 12, 2014 at 10:52 KarthikaKarthika 1031 gold badge2 silver badges13 bronze badges 4
  • 2 can you explain more? – Anoop Joshi P Commented Mar 12, 2014 at 10:53
  • what exactly you want's to do.. – Rahul Kumar Commented Mar 12, 2014 at 11:01
  • I have Three button on the same page with three different actions .k – Karthika Commented Mar 12, 2014 at 11:09
  • when first button is clicked .he can able to click second button .then third.when he clicked the second button directly it will not work – Karthika Commented Mar 12, 2014 at 11:11
Add a ment  | 

5 Answers 5

Reset to default 5

Initially disable second and third button using :

<input type="button" value="button" id="two" onclick="show1()" disabled="disabled"/>
<input type="action" value="button" id="three" disabled="disabled"/>

And Use this code :

function show()
{
    document.getElementById('two').removeAttribute('disabled');
}
// And Same For Second Button Click
function show1()
{
    document.getElementById('three').removeAttribute('disabled');
}

jQuery would be better here:

$('#one').click(function () { // on a click on the button with id 'one'
  $('#two').trigger('click');// trigger the click on second, and go on 
}

Using this method you can trigger events on other elements using an event on a particular element!

    <script>
    function show(){ 
$('#button1').attr('disabled',false);
$('#button2').attr('disabled',false);

    }
    function show1(){
$('#button2').attr('disabled',false);
    }
    </script>

Are you looking for this

$("input").click(function(){
 $("input").attr('disabled','disabled');
$(this).next().removeAttr('disabled');

});

Demo

you can use Jquery to bind an event to the click. and there do what you want:

$('#ButtonID').bind('click',function(){
   $('#ButtonID2').show(); 
    //or
   $('#ButtonID1').removeAttr('disabled');//if you want it be shown but not enabled
});

this is for disableing the buttons:

 $('#ButtonID').attr('disabled','disabled');

本文标签: jqueryactivate button after another button click in javascriptStack Overflow