Im trying to do some basic stuff with javascript, to get it to generate some website content automatically,, but its driving me crazy!!! Could someone please show me a simple example of how to do get javascript to create new images and paragraphs in divs.. lets say my website structure is like this…
<html>
<head>
</head>
<body>
<div id ="wrapper">
<div id ="content">
</div>
</div>
</body>
</html
how would I use a javascript function to create images and paragraghs in the “content” div on-loading the page and also on-clicking an image. I know it has to with the DOM but Ive been at this for hours and I just cant get it to work! Please show me an example of how its done. Thanks a lot in advance!!!!!!
In its simplest form:
JS Fiddle demo.
References:
element.appendChild().document.createElement().document.createTextNode().