Can anyone tell me why, with the following code, when I click “Click Here”, the text doesn’t change to “test”?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<div id="thisdiv" onClick="document.getElementbyID('thisdiv').innerHTML='test'">Click Here</div>
</body>
</html>
You have a lowercase
band an uppercaseD.Example: http://jsfiddle.net/qSEpF/
But simpler would be to reference the current element with
this:Example: http://jsfiddle.net/qSEpF/1/