How to disable HTML button using JavaScript?

0 votes

I’ve read that you can disable an HTML button simply by appending disable to its tag, but not as an attribute, as follows:

<input type="button" name=myButton value="disable" disabled>

Since this setting is not an attribute, how can I add this in dynamically via JavaScript to disable a button that was previously enabled?

Oct 9 in Java-Script by kartik
• 35,820 points
27 views

1 answer to this question.

0 votes

Hello @kartik,

To disable

document.getElementById("btnPlaceOrder").disabled = true; 

To enable

document.getElementById("btnPlaceOrder").disabled = false; 

Hope it helps!!
Thank you!!

answered Oct 9 by Niroj
• 78,120 points

Related Questions In Java-Script

0 votes
1 answer
0 votes
1 answer

How to convert HTML to JSON using PHP?

Hello @kartik, If you are able to obtain ...READ MORE

answered Jun 19 in Java-Script by Niroj
• 78,120 points
1,165 views
0 votes
1 answer

How to add affiliate links automatically to blog post using javascript?

Hello @ Okugbe ,  You need few lines of code, ...READ MORE

answered Aug 9 in Java-Script by Niroj
• 78,120 points
156 views
0 votes
1 answer

How to open a URL in a new Tab using JavaScript or jQuery?

Hello @kartik, Use window.open(): var win = window.open('http://edureka.co/', '_blank'); if (win) ...READ MORE

answered Aug 25 in Java-Script by Niroj
• 78,120 points
330 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27 in Java-Script by Niroj
• 78,120 points
448 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5 in Java-Script by Niroj
• 78,120 points
697 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8 in PHP by Niroj
• 78,120 points
91 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8 in Node-js by Niroj
• 78,120 points
87 views
0 votes
1 answer

How to Scroll to the top of the page using JavaScript?

Hii @kartik, Using javascript <script> $("a[href='#top']").click(function() { ...READ MORE

answered Apr 2 in Java-Script by Niroj
• 78,120 points
83 views
0 votes
1 answer

How to Store PHP variable with HTML in JavaScript in Laravel Blade Template?

Hello @kartik, The double curly brackets {{ }} will always ...READ MORE

answered Jun 11 in Java-Script by Niroj
• 78,120 points
3,734 views