I do not speak JavaScript, but it looks like there is an unnecessary semicolon after the word ‘blue’, onmouseover="this.style.backgroundColor='blue';
(Disclaimer: I do not know if the JS is valid or not. Just guessing about a possible “inconsistency”.)
For my own benefit and learning, I dabbled with your JavaScript.
Because some of the JS styles were terminated with semicolons and others were not, I decided to see what would happen if I removed the semicolons from all of them. They all still worked. Apparently, all that is needed is a space between them.
I then moved the inline CSS styles of the top div to the top of the page, again for my benefit, to remove the clutter from the HTML and make them easer to read.
Finally, I removed the JS code for styles already defined in the CSS.
(You can return the CSS in the head section of the page to inline styles within the div very easily, if that floats your boat :). The JS will not need to change)
Thank you for helping me learn something about JS.
Why wait for the next chapter? We can dramatically improve things now without needing to invoke a listener, by moving the terrible inline CSS style out to their own CSS declarations.
The onmouseover styles can be placed in their own declaration, and the onmouseout isn’t needed for they just return the styles back to what is currently the default in the div declaration.
As such, we just need a :hover declaration, and to remove those god-awful onmouseover and onmouseout attributes:
Which leaves the HTML with the onmouseover and onmouseout taken out, looking quite empty now:
<div></div>
We can target it more effectively, by giving it and the CSS declaration a class name:
<div class="bars"></div>
div.bars:hover {
...
}
We can also get rid of the embedded styles from the second div, by giving it a class of “hover” and adding the .hover part to the CSS declaration, which leaves us with HTML of:
asasass is a special needs member with … special needs. He needs wants all of the scripts and styles to be written inline within the HTML elements. I was playfully goading him to think outside of the [inline] box. No one would use inline JS for hover behaviors except outdated Dreamweaver users AFAIK.
The serious side to my post is that I actually did learn a trace more about JS by playing with his code.
Needs? So there is a genuine reason for it? If so, perhaps you could enlighten me, because I’ve missed it along the way. I thought it was just “wants”.
(I’ve already advised against going the JavaScript route for this, so it’s good to see a JS Guru like @Paul_Wilkins agrees with me. )
asasass is a special needs member with … special needs. He needs wants all of the scripts and styles to be written inline within the HTML elements.[/quote]
Thanks for the update but somehow I think that I’ll want to gain confirmation and possibly even clarification from our special needs patient.
It is just wants - - can’t be bothered to learn HTML properly so why learn how to write the CSS and JavaScript (when applicable) properly in separate files either.
We have already determined that in every situation where needs was stated that external CSS is available.