Change selected item in jQuery - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Change selected item in jQuery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <title>Selector Item</title> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.js"></script> 
  <script type="text/javascript">
    window.onload=function(){/*  ww w  .jav  a 2 s .  com*/
$('#my').val('3');

    }

      </script> 
 </head> 
 <body> 
  <select id="my"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select>  
 </body>
</html>

Related Tutorials