Here, I need to display div contents based on the dynamic value which I get from json array.
JSON Object
{"userid":"12345","cmpyname":"stackoverflow",
"starrays": [{"transaction":"7272785","value2":"GOOGLE"}, //Array [0]
{"transaction":"85785272","value2":"YAHOO"}, //Array [1]
{"transaction":"4774585","value2":"REDIFF"}], //Array [2]
"value3":"95345"}
From the above received JSON object, I am setting the value to the respective div element as like below.
$('#somedivid').html(data.userid); //normal json object
$('#somedivid').html(data.starrays[0].value2); //json array object
$('#somedivid').html(data.starrays[0].transaction); //json array object
Here, if I have any values in value2 and transaction array, it should display outer div.
Otherwise, it should hide.
<div id="outer">
<div id="verbiage1" class="ver1">
Value 2:
</div>
<div id="val">
<!-- dynamic value populate here -->
</div>
<div id="verbiage2" class="ver2">
Transaction:
</div>
<div id="amt">
<!-- dynamic value populate here -->
</div>
</div>
How to achieve this using jquery?