I'm using javascript to set the style of my button onmouseover and onmouseout. The main idea is that when the user mouse's over the button it changes and then onmouseout it changes back to normal. I've tried everything i can think of but cannot resolve my error. I keep getting the error "Uncaught TypeError: Cannot read property 'style' of null".
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
Both buttons will ALWAYS have an indexOf("start_button") > -1 (both IDs begin with "start_button" and that will never change.)
The error message means that document.getElementById(x) is null.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
You should never use != or == in JavaScript as they are considered to be extremely sloppy and error prone ways to code. Those comparisons will fail when you validate your code though jslint.com because they are likely to cause errors. That was the only piece of modern JavaScript coding that the OP was using.
If the types are known to differ before comparing then you should convert them to the same type yourself before comparing them.
When comparing a variable to a fixed value put the fixed value on the left as that makes it easier to detect typos.
You should never use != or == in JavaScript as they are considered to be extremely sloppy and error prone ways to code. Those comparisons will fail when you validate your code though jslint.com because they are likely to cause errors.
I frequently use != and == and do not consider it sloppy or necessarily error prone.
Code:
if (fruit == 'banana') {
If I know that fruit is a string then I am happy with this expression. jslint is over-zealous.
Quote:
If the types are known to differ before comparing then you should convert them to the same type yourself before comparing them.
Yes, but having made the conversion there is no need for ===. JS is dynamically-typed and type-conversion should be used where necessary or appropriate.
Quote:
When comparing a variable to a fixed value put the fixed value on the left as that makes it easier to detect typos.
I always put the variable on the left and will continue to do so - it looks more natural to me. If there is a typo I will discover it. I appreciate that, for a beginner, it might be useful that
Code:
54 = someVariable
is flagged as an error, but it just looks wrong (in Western eyes) - this is more important to me.
These are my considered opinions and, as always, are not provided as statements of immutable fact.
Quote:
In philosophy and logic, an immutable truth is an unchanging universal fact or reality that is not influenced by human opinion. According to positivism, observation and experience are the only ways for immutable truths to become fully realized or understood.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-08-2012 at 08:52 AM..
I frequently use != and == and do not consider it sloppy or necessarily error prone.
Code:
if (fruit == 'banana') {
If I know that fruit is a string then I am happy with this expression. jslint is over-zealous.
Yes, but having made the conversion there is no need for ===. JS is dynamically-typed and type-conversion should be used where necessary or appropriate.
I always put the variable on the left and will continue to do so - it looks more natural to me. If there is a typo I will discover it. I appreciate that, for a beginner, it might be useful that
Code:
54 = someVariable
is flagged as an error, but it just looks wrong (in Western eyes) - this is more important to me.
These are my considered opinions and, as always, are not provided as statements of immutable fact.
I have to say that entirely agree with your remarks. But as always chacun à son goût applies. People should not claim that their own personal preferences are the only "valid" or "correct" approach when there are equally acceptable alternatives.. That is the thin end of the fanticism wedge.
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 12-08-2012 at 09:08 AM..
Reason: Noticed typo
People should not claim that their own personal prefernces are the only "valid" or "correct" approach.
Exactement! Hence the 'disclaimer'. Ouvrir la porte!
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
Last edited by AndrewGSW; 12-08-2012 at 09:11 AM..
Reason: Kept Philips' typo, he, he!
And ev'ryone will say,
As you walk your mystic way,
"If that's not good enough for him which is good enough for me,
Why, what a very cultivated kind of youth this kind of youth must be!"
- W.S.Gilbert, Patience
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
“I have opinions of my own - strong opinions - but I don't always agree with them.”
― George H.W. Bush
Andy.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS