setAttribute using Function()
-- example 1 --
<input value="OK" onclick="myVal()"disabled >
<button onclick="myFunction()">Try it</button>
script>
function myFunction(x) {
document.getElementsByTagName("INPUT")[0].setAttribute("type", "button");
document.getElementsByTagName("INPUT")[0].disabled = false;
}
function myVal() {
alert('This is button')
}
</script>
-- example 2 --
<button id="btnSend">Send</button>
<script>
let btnSend = document.querySelector('#btnSend');
if (btnSend) {
//btnSend.setAttribute('name', 'send');
//btnSend.setAttribute('disabled', '');
//alert('This is work automatically');
//btnSend.setAttribute("style", "background-color: red;");
}
</script>
Comments
Post a Comment