0
Just run this code and help me figure out what I'm doing wrong
https://code.sololearn.com/W7sklZIOC4vM/?ref=app Not sure why it's not working. I know I'm not smart, but bear with me. xD I'm trying to set the buttons attribute to "disabled" when you hover over the div. Keeps saying it can't set property of null. Don't know why.
11 Réponses
+ 4
You are executing the MouseEvents().
should be
window.onload = MouseEvents;
+ 1
hi man, in external js better use this:
window.addEventListener('load', function(){ // Everything has loaded!
MouseEvents();
});
that your solution better use in html codes, at the end of that or event load attribute body tag...
+ 1
for work on touch use mouseleave instead of mouseout
and read about mouseenter too.
+ 1
yes its true. you can test it by change target event element to your btn.
and i want to know,
when you need an disabled element run an event? in which subject(project or any other reason to do this)?
+ 1
an element set disabled to do nothing. you disable an light by turn it off to do nothing(do not light)
sorry, i can't speak english good.
now you want an function run by event of disabled element. such as mouseover...
when and where this have usage?
+ 1
I can't see anywhere it would have usage. I was really just setting a goal for myself to test myself and learn in the process. Setting goals helps me learn better.
0
Luckily, I figured it out right after posting it. I didn't use this, I just surrounded it in a window.onload and it worked fine. Then I tested your method and it worked. Now I have one more question if you don't mind.
Why do mouseout events seem to not work with buttons?
0
I read online that disabled elements can't run scripts, is this true?
0
I was half asleep when I typed that.
The actual wording was " Disabled elements cannot fire events "
0
I tested it a few times, but didn't know exactly why it wasn't working.
And can you repeat the question? I'm having trouble understanding it.
0
I still haven't achieved it yet, so I'm going to try surrounding it by a div and adding the event handlers to it.