Use id in HTML button and removeChild method to remove button Using JavaScript.
Example code remove HTML button Using JavaScript
In the example we have 2 buttons:
- First Will remove
- Second will remove first button
The action button will call function, where find the element by id then use removeChild method to remove button in JS.
<html>
<body>
<input type="submit" id="dummy" disabled value="Submit" />
<input type="button" value="Remove DUMMY" onclick="removeDummy()" />
</body>
<script>
function removeDummy() {
var elem = document.getElementById('dummy');
elem.parentNode.removeChild(elem);
return false;
}
</script>
</html>
Output:
Do comment if you have any doubts and suggestions on this topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version