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

enter image description here

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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -