Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You have an invalid JSON structure. The correct structure is below:</p> <pre><code>[ { "chapter": "General", "title": "News forum", "content": "Text1" }, { "chapter": "CHAPTER 1", "title": "1.1 Introduction", "content": "Text2" }, { "chapter": "CHAPTER 1", "title": "1.2 Main Idea", "content": "Text3" }, { "chapter": "CHAPTER 2", "title": "2.1 Architecture", "content": "Text4" }, { "chapter": "CHAPTER 3", "title": "3.1 Liter.overview", "content": "Text5" } ] </code></pre> <p>Note that comma here <code>3.1 Liter.overview","content":"Text5"},</code> in your JSON structure, it fails here</p> <p><strong>UPDATED ANSWER WITH CODE</strong></p> <pre><code>var jsonString = '[{"chapter": "General","title": "News forum","content": "Text1"},{"chapter": "CHAPTER 1","title": "1.1 Introduction","content": "Text2"},{"chapter": "CHAPTER 1","title": "1.2 Main Idea", "content": "Text3"},{"chapter": "CHAPTER 2","title": "2.1 Architecture","content": "Text4"},{"chapter": "CHAPTER 3","title": "3.1 Liter.overview","content": "Text5"}]'; var myData = JSON.parse(jsonString); $(document).ready(function() { function dContent() { $("#content").css("border","2px solid red").css("height","100px"); $("#content").html($(this).data('value')); } $("#courses").on('click','li', dContent) $.each(myData, function(index,item) { $("#courses").append("&lt;li class='li' data-value="+item.content+"&gt;"+item.chapter+" &lt;p&gt;"+item.title+"&lt;/p&gt;&lt;/li&gt;"); }) }); </code></pre> <p><a href="http://jsfiddle.net/refhat/Yfdcx/" rel="nofollow"><strong>DEMO ON JSFIDDLE</strong></a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload