JQuery set selected index for <select> - Javascript jQuery

Javascript examples for jQuery:Select Dropdown

Description

JQuery set selected index for <select>

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-2.1.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* w w  w.  j a  v  a  2 s. com*/
$('select').get(0).selectedIndex = 2;
    });

      </script> 
 </head> 
 <body> 
  <select> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select>  
 </body>
</html>

Related Tutorials