I have this following JSON data snippit:
{"items": [
{
"title": "sample 1",
"author": "author 1"
},
{
"title": "sample 2",
"author": "author 2"
}
]}
How do I populate the following html elements with this data:
<div class="news-story">
<h5>sample 1</h5>
<p>By: author 1</p>
<h5>sample 2</h5>
<p>By: author 2</p>
</div>
I want accomplish this with Javascript not jQuery.
Loop through them and use the DOM functions:
http://jsfiddle.net/AWRAW/
getElementsByClassNamewill not work in versions of IE prior to 9. If you need to support those though, you’re really better off using jQuery.