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.

5th Jun 2018, 9:05 PM
Daniel Cooper
Daniel Cooper - avatar
11 Réponses
+ 4
You are executing the MouseEvents(). should be window.onload = MouseEvents;
5th Jun 2018, 9:17 PM
Toni Isotalo
Toni Isotalo - avatar
+ 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...
5th Jun 2018, 9:29 PM
Mohammad Mehdi Takalloo
Mohammad Mehdi Takalloo - avatar
+ 1
for work on touch use mouseleave instead of mouseout and read about mouseenter too.
6th Jun 2018, 11:22 AM
Mohammad Mehdi Takalloo
Mohammad Mehdi Takalloo - avatar
+ 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)?
6th Jun 2018, 8:06 PM
Mohammad Mehdi Takalloo
Mohammad Mehdi Takalloo - avatar
+ 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?
6th Jun 2018, 8:29 PM
Mohammad Mehdi Takalloo
Mohammad Mehdi Takalloo - avatar
+ 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.
6th Jun 2018, 8:33 PM
Daniel Cooper
Daniel Cooper - avatar
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?
5th Jun 2018, 9:26 PM
Daniel Cooper
Daniel Cooper - avatar
0
I read online that disabled elements can't run scripts, is this true?
6th Jun 2018, 6:46 PM
Daniel Cooper
Daniel Cooper - avatar
0
I was half asleep when I typed that. The actual wording was " Disabled elements cannot fire events "
6th Jun 2018, 7:50 PM
Daniel Cooper
Daniel Cooper - avatar
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.
6th Jun 2018, 8:08 PM
Daniel Cooper
Daniel Cooper - avatar
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.
6th Jun 2018, 8:35 PM
Daniel Cooper
Daniel Cooper - avatar