benjamin.morgan
New Member
Why doesn't this work? I have the code in a JSFIDDLE if you want to run it at http://jsfiddle.net/ZTGL7/2/
HTML
CSS
Javascript
HTML
Code:
<div id="red"></div>
<input type="button" id="clickme" value="Click Here">
CSS
Code:
#red {
background: red;
height: 100px;
width: 100px;
}
#blue {
background: blue;
height: 100px;
width: 100px;
}
Javascript
Code:
function change() {
var red = document.getElementById('red');
red.id = "blue";
}
function init() {
var clickme = document.getElementById('clickme');
clickme.onclick = change;
}
window.onload = init;