jquery - How can i have all the li tags under the ul tag? -
i getting response server
{ "vendors": { "t1": [ { "name": "raj cool drinks", "leaf": [ { "toppings": [ { "name": "quantity 1", "value": [ "honey chocolate sauce 10 ml", "honey carmel 10 ml" ] } ] } ] } ] } } (var l = 0; l < toppins.length; l++) { var toppul = '<ul>'; $.each(toppins[l].value, function (i, text) { if (text != '' && text != undefined) { toppul += "<li>" + text + "</li>"; } toppul += "</ul>"; }); }
with above code , output being formed way
<div class="crust-topping-detailswrap"> <h5>item 1</h5> <h6>toppings</h6> <ul> <li>honey chocolate sauce 10 ml</li> </ul> <li>honey carmel 10 ml</li>
and screen looks way
how can have text under ul ??
so output way
<ul> <li>honey chocolate sauce 10 ml</li> <li>honey carmel 10 ml</li> </ul>
move following statement outside .each loop
toppul += "</ul>";
$.each(toppins[l].value, function(i, text) { if(text!=''&&text!=undefined) { toppul += "<li>" + text + "</li>"; } }); toppul += "</ul>"; // out side .each loop
Comments
Post a Comment