Trying to do something more complex, but I seem to not understand the basics of adding styles to elements? What am I doing wrong?
http://jsfiddle.net/TAvtJ/ Trying to do something more complex, but I seem to not understand the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The problem is that jsfiddle defaults to putting your code in an
onloadhandler, which means yourchangeColor()function was not a global function and wasn’t accessible from inline event attributes.If you look to the left of the jsfiddle page you can choose a framework to include (it defaults to MooTools, but you can use jQuery and various others) and choose whether your JavaScript will be in the head, the body, an onload handler or onDOMReady handler.
So your code works if you include it in the head or body: http://jsfiddle.net/TAvtJ/1/