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
Post a Comment