I am an absolute beginner, and thought that I'd see if i could copy this seemingly basic project (http://jenniferdewalt.com/random_background.html). Rather than just copy the code, I want to figure out why I can't get it to work. I really have no idea how JS interacts with HTML. Here's what i've got:
HTML:
<link type="text/css" rel="stylesheet" href="../../CSS/randomcolor/randomcolour.css" /> <link type="text/javascript" src="../../JS/Random Colour/randomcolour.js"> <script type="text/javascript" src="../../JS/Random Colour/randomcolour.js"></script> </head> <body> <a href="javascript:void(0)" onclick="randomColor()";> <div .class="button" id="button"> <h2></h2> </div> </a> JS:
function randomColor() { return '#' + Math.random().toString(16).slice(2, 8); }; var backgroundColor = randomColor() This is all probably a million miles off the mark, so if anyone can point me to a resource that will help me out at all, it'd be much appreciated. It's so frustrating not being able to figure this out!
randomColor(), but you don't do anything with the return value.