set selected index on change for <select> - Javascript jQuery

Javascript examples for jQuery:Select Dropdown

Description

set selected index on change 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-1.6.2.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from www . ja v a 2  s. c om
$("select").change(function(){
    $(this).children(":first").attr('selected','selected');
});
    });

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

Related Tutorials