I have following div tag with child tags.
<div class="span6"> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> </div> And I wanna append child <div class="control-group"></div> to parent <div class="span6"></div> according to the array. So I have written the javascript is as below.
$.each(categories, function (k, elem) { var options = ''; var options = ' <div class="control-group"> <label for="StockCategory">Category</label> <div class="controls"> <select class="input-xlarge get-category"> '; options +='<option value="">Select Category</option>'; $.each(data, function(key, value) { options += '<option value="' + key + '">' + value + '</option>'; }); options +=' </select> </div> </div>'; $("div.span6").append(options); } So I wanted to append these child divs according to array but Its not happening. So I needed the following result.
<div class="span6"> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">Item Name</label> <div class="controls"> <input type="text" id="inputEmail" class="input-xlarge" placeholder="Enter item name here..."> </div> </div> </div> Please help me to get it. The work is more appreciated.
So I needed the following result....and i don't see anything withStockCategoryand so on... are you saying u just need to clone the first div ... seeing you result looks like that is what u want...datafor the second each loop ???