javascript - Set dropdown list from server value on dynamic created div -
i have problem setting value of dropdown list in dynamic created div
edit form.
document.getelementbyid("edit-entry").innerhtml = ""; var div = document.createelement('div'); div.classname = 'edit'; div.innerhtml = "form html"; document.getelementbyid('edit-entry').appendchild(div);
in html
<div id="edit-entry"></div>
on console it's working ("#sel-change-app").val("9");
when try under appendchild
, or $(function() { }
still no change. how check if div
ready setting values? debug see sel-change-app slower div, couse list server.
hope you..
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('select#sel').find('option').each(function() { var t=$(this).val(); $("#myselect").append(t+"<br>"); }); }); </script> </head> <body> <select id="sel" name="sel"> <option value="o1">1</option> <option value="o2">1</option> <option value="o3">1</option> <option value="o4">1</option> </select> <div id="myselect"></div> </body> </html>
Comments
Post a Comment