title: Is it possible to set the only first element on span in for loop?
body: <p>I want to set only first element on the span in for loop. Everything is working fine in the code but it's setting the last element on the span. I want to set the first element as <code>cust_name</code>.</p>
  
  <pre><code>success : function(data) {
  
                          console.log(data);
  
                          var jsonData = jQuery.parseJSON(JSON.stringify(data));
  
                          for (var i = 0; i &lt;= jsonData.categories.length; i++) {
                              var counter = jsonData.categories[i];
  
                              var cust_id     = counter.cust_id;
                              var cust_name   = counter.cust_name;
                              var cust_phone  = counter.cust_phone;
  
                               $('input[name="customer"]').val(cust_id);
                              $('#customernames').text(cust_name);
  
                              if (cust_phone=="") {
  
                  $("#dropselect-demo1").append('&lt;li onclick="setcustomer(\'' +cust_id+ '\',\'' +cust_name + '\',\''+cust_phone + '\')" class="list-group-item"&gt;'+cust_name+'&lt;/li&gt;');
  
  
                              }else{
                   $("#dropselect-demo1").append('&lt;li  onclick="setcustomer(\'' +cust_id+ '\',\'' +cust_name + '\',\''+cust_phone + '\')"  class="list-group-item"&gt;'+cust_name+' [ '+cust_phone+' ]&lt;/li&gt;');
  
                              }      
  
                          }
  
  
                      }
  </code></pre>