I have an array as below:
[{
"category_type": 1,
"category": 2,
"name": "gut",
"description": "bg",
"registered_location": "1234 1234",
"current_location": null,
"contact_person": 4046,
"barcode": "25757767",
"nfc_tag_id": "44444543",
"unit_of_measure": "crate",
"date_added": "2014-11-13",
"status": 1
}]
I am able to loop through it and get all the values like this:
$.each(data, function(key, object){
$.each(object, function(key, value){
console.log(value);
})
})
I have a certain number of spans that I'd like to get their texts from the different values.The spans are like:
<p>Category Type: <span></span></p>
<p>Category: <span></span></p>
<p>Name: <span></span></p>
<p>Description: <span></span></p>
<p>Registered Location: <span></span></p>
<p>Current Location: <span></span></p>
<p>Contact Person: <span></span></p>
<p>Barcode: <span></span></p>
<p>NFC Tag ID: <span></span></p>
<p>Unit of measure: <span></span></p>
<p>Date Added: <span></span></p>
<p>Status: <span></span></p>
I want all the empty spans above to get their texts from the JSON values I get above. How can I achieve this?
var span = $('<span />').html(value); $( "body" ).append( span );