JQuery Append option to Dropdown <select> - Javascript jQuery

Javascript examples for jQuery:Select Dropdown

Description

JQuery Append option to Dropdown <select>

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>SO - 5179723</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   ww  w . ja  va  2 s  .c o  m*/
 $("<option />").val("test1").text("test2").appendTo($("select"));
    });

      </script> 
   </head> 
   <body> 
      <select></select>  
   </body>
</html>

Related Tutorials