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

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -