Manipulating Dom With (framework-less) Javascript
Ok, I haven't been using JavaScript without JQuery for quite some time now... But, as coding goes, I have to do without it's power for a project where I can't be sure that JQuery i
Solution 1:
It's innerHTML
not innerHtml
. Notice the upper case HTML
. Change that and it should work fine! Here's a working example.
By using innerHtml
you are simply creating a new property on the element object and giving it the value of s
.
Solution 2:
<html><head><scripttype="text/javascript">functionload() {
var s = '<ul><li>a</li><li>b</li></ul>';
var element = document.getElementById("myDiv");
element.innerHTML += s;
}
</script></head><bodyonload="load()"><divid="myDiv"></div></body></html>
JS is case sensitive
Solution 3:
I think you want element.innerHTML += s;
.
Post a Comment for "Manipulating Dom With (framework-less) Javascript"