html - Javascript taking div data with JS -
html:
class="lang-html prettyprint-override"><div class="takeidfromhere">400788381251</div>
javascript:
class="lang-html prettyprint-override"><script> var id = document.getelementsbyclassname('.takeidfromhere'); for(var i=0; < id.length; i++) { document.write('\<div class="testclass">'+id[i]+'</div> \ '); } </script>
my point is, javascript must run when document ready. did not work.
where mistake?
it's stray period.
var id= document.getelementsbyclassname('takeidfromhere')
this should work. document.write
code might not think it's doing. \
characters don't create sense me, nor way you're using id[i]
. seek replacing document.write("test")
or , go there.
javascript html
No comments:
Post a Comment