+ 1
try to make the button disabled but error
i am making disabled button with disabled property in javascript but why error please explain to me why this error happened https://code.sololearn.com/W8WI0xpdfdh7/?ref=app
3 Respuestas
+ 7
Because you element doesn't exist
const rButton;
window.onload = function() {
rButton = document.getElementById("removeBtn");
rButton.disabled = true;
}
+ 1
You must make sure that DOM is avaible at getElementById time else any call for get elements references return null.... Try to wrap your js code in a function that set like window onload listener:
window.onload= function(){
// your js code here
}
+ 1
when i use window.onload html can not access function