Scroll select box to specific option without changing selected value - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Scroll select box to specific option without changing selected value

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.8.3.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*  w w w.  j  a v a  2  s  .c  o  m*/
var h = '';
for (i = 1; i < 200; i++) 
   h += '<option value='+i+'>'+i;
$('#s').html(h).val(40).scrollTop(160);
    });

      </script> 
 </head> 
 <body> 
  <select id="s" size="10"></select>  
 </body>
</html>

Related Tutorials