I have a div with id xyz.Now i have avariable which has some html code like follows
var mycode = "<br>jajaj<b>jjja</b> ";
Now i want to replace content of div with this html code by using following
document.getElementbyid("xyz").innerHTML = mycode
This doenot work.I am not getting why.mycode is dynamica开发者_开发问答llly created in my code.
if i do simple document.getElementById("xyz").innerHTML ="some text"
this works
getElementById()
is case sensitive.
You had missed semicolon
document.getElementbyid("xyz").innerHTML = mycode;
Have you type your code in this manner?
<html>
<body>
<div id="xyz"></div>
<script>
var mycode = "<br>jajaj<b>jjja</b> ";
document.getElementById("xyz").innerHTML = mycode;
</script>
</body>
</html>
This one worked for me. Please post your sample code so that we can see it.
精彩评论