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