Append to a jQuery object in order without using a parent $('<div>') - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:append

Description

Append to a jQuery object in order without using a parent $('<div>')

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from  w ww .  ja v  a  2s.  co  m
var options = [];
for (var i = 0;i < 10; i++) {
     var $option = $('<option/>')
     $option.text(i);
     $('.target-class').append($option);
}
    });

      </script> 
 </head> 
 <body> 
  <select class="target-class"></select>  
 </body>
</html>

Related Tutorials