dimanche 1 février 2015

Advice with this javascript code?


I’m attempting to learn how build my own website. I have Linda.com membership and I’m attempting to complete a tutorial about web design fundamentals. This chapter is on javascript.


Previous chapters were on html and css.


The lesson was to create a button and when clicked it would change the p content a different colour.


My code copied from a TextEdit file is;


Exploring HTML body { color: red; } h1{ font-family: Arial,sans-serif; font-size:32px; Color:black; }


My First Web Page


This is my first web page, it is a little basic, but its helping me understand how HTML works and how to mark up my content.


Change color!


document.getElementById(‘color’).onclick = changeColor; var currentColor = “red”; function changeColor() { if(currentColor == “red”){ document.body.style.color = “green”; currentColor = “green”; } else { document.body.style.color = “red”; currentColor = “red”; } return currentColor; }

I’ve tried both spellings of colour and color and its still not working. I'm working on a mac would that make any difference?


Any suggestions would be welcome.





Aucun commentaire:

Enregistrer un commentaire