Clicking one button then activate another button

Susant

I want to click 1st button then activate 2nd button. After 2nd button is activated, 1st button will be disabled. I wrote the code below but it is not working. Where is the problem?

<!DOCTYPE html>
<html>
<head>
<title>Edit Page</title>
</head>
<body>
<input type="submit" name="submit" value="button1" id="bt1">
<input type="button" name="button" value="button2" id="bt2" disabled="disabled">
</body>
<script>
$(function(){
        $("#bt1").click(function(){
            $(this).attr("disabled", "disabled");
            $("#bt2").removeAttr("disabled");
        });

        $("#bt2").click(function(){
            $(this).attr("disabled", "disabled");
            $("#bt1").removeAttr("disabled");
        });
    });
</script>


</html>
Palani Samy

Include jQuery library file at the top of head tag like this:

<html>
<head>
<title>Edit Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>$(function(){
$("#bt1").click(function(){
$(this).attr("disabled", "disabled");
$("#bt2").removeAttr("disabled");
});

$("#bt2").click(function(){
$(this).attr("disabled", "disabled");
$("#bt1").removeAttr("disabled");
});
});
</script>
</head>
<body>
<input type="submit" name="submit" value="button1" id="bt1">
<input type="button" name="button" value="button2" id="bt2" disabled="disabled">
</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Change visibility of one button by clicking another button

iOS Swift - Why does clicking on 1 button activate another button when 1 button overlays the other

Clicking on one button calls the actionListener of another button in JAVA Swing

How to activate a cell on clicking a radio button in Excel?

activate the toggle on one button at a time

Radio button stays checked after clicking another one

How to send extra Data and have it one after another by clicking a button

I have 2 UI tabs. I need to activate one specific tab on clicking a button outside that tab

how to style a button after clicking another button?

display a button after clicking another button

Start another activity by clicking a button

Activate a dropdown option from another button/llink

How to activate location when clicking on button using google maps flutter?

jQuery: navigate to another page by clicking a button

Adding another input field when clicking on a button

Angular: Submit method executed by clicking another button

How to call another function on clicking of Modal button?

Fromik clicking on another button on hitting enter

Close menu when clicking the screen or another button

Clicking on button to redirect to another html page

Clicking a button which is inside another element Selenium

Clicking button to add its text to another div

A button do thing on clicking & undo it on another click

How to go to another page by clicking a button in React

Displaying one List at a time on Clicking button

Scroll 3 divs with on clicking one fixed button

My Output repeats by one time on clicking the button

How can I add a row to a ListView in one Fragment by clicking the button in another Fragment?

Changing from one namespace to another when clicking a submit button in Struts 2