Javascript Question: Misunderstand either getElementbyID or innerHTML -


can tell me why, following code, when click "click here", text doesn't change "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 lowercase b , uppercase d.

 //-------v------should uppercase getelementbyid  //----------^---should lowercase 

example: http://jsfiddle.net/qsepf/


but simpler reference current element this:

onclick="this.innerhtml='test'" 

example: http://jsfiddle.net/qsepf/1/


Comments

Popular posts from this blog

mod rewrite - Doing external redirect. .htaccess NS flag not working. How to achieve similar results? -

mysql - How to insert just year and month into date field? -