javascript - Appending a new drop down selector using jquery .append method -
i wanting add anther drop down selector every time press button. using jquery add new drop down field, however, unable new drop down selector added. code not working. below code:
jquery:
$(document).ready(function(){ existingdiv1 = document.getelementbyid( "dropdown" ); $("#btn1").click(function(){ $("z").append('<strong>hello</strong>', existingdiv1); }); });
html:
<div class="control-group"> <div class="controls"> <z> <select id="servingsizeunits" class="selectpicker btn-medium btn-block" data-style="btn-info" name="dropdown" id="dropdown"> <optgroup label="select product type"> <option name="dropdown" value="val1">val1</option> <option name="dropdown" value="val2">val2 </option> <option name="dropdown" value="val3">val3</option> <option name="dropdown" value="val4">val4</option> <option name="dropdown" value="val5">val5</option> </optgroup> </select> </z> </div> </div> <button id="btn2" class="btn btn-primary" data-activate="#payment" type="submit">add selector</button>
any suggestions great.
update 1: have made sure , fiddle code same.
first of havent included jquery in fiddle..i have updated fiddle , im attaching here. http://jsfiddle.net/ar9r9/2/
$(document).ready(function(){ $("#btn2").click(function(){ $(".app").append('<input class="input-block-level" type="text" name="newfield" id="newfield" placeholder="new field">' ); }); });
here im appending selector div thats enclosing select.
Comments
Post a Comment