javascript - store jquery data in html element -


i want store data getjson in html element list.
here script data.js:

$.getjson("dataset.json", function(obj) {     obj.types.foreach(function(key) {         console.log(key.type);     }); }); 

the console log list of keys:

one 2 3 4 

and html code:

<div class="row">     <div class="col-sm-offset-1 col-sm-11 col-md-offset-1 col-md-11">         <div class="item-group">             <label class="item-label">list</label>                 <ul class="list-unstyled" id="datalist"></ul>             <br>         </div>     </div> </div> 

how can pass result getjson id="datalist" ?

//example data  var data = [{value:'one'},{value:'two'},{value:'three'},{value:'four'}];  data.foreach(function(item){   $('#datalist').append('<li>'+ item.value +'</li>');  });  //selects element id #datalist , adds each value 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div class="row">      <div class="col-sm-offset-1 col-sm-11 col-md-offset-1 col-md-11">          <div class="item-group">              <label class="item-label">list</label>                  <ul class="list-unstyled" id="datalist">                  </ul>              <br>          </div>      </div>  </div>


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -