JavaScript - Can't assign variable -


my simple code :

var child1 = document.getelementsbyclassname("item1")[0].innerhtml; var child2 = document.getelementsbyclassname("item2")[0].innerhtml; var child3 = document.getelementsbyclassname("item3")[0].innerhtml; var child4 = document.getelementsbyclassname("item4")[0].innerhtml; var arr = [child1, child2, child3, child4]; 

but when run document in firefox, open console , type child1, or type arr, undefined in console.

when type, say, document.getelementsbyclassname("item1")[0].innerhtml;, right content in console, :

"<div class="inh">♠</div>" 

this content, can't assign variable !! great.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -