Javascript examples for jQuery:Selector
Populate select box using jquery $.each()
<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(){//from w w w. j av a 2 s . c om var years = [2010, 2011, 2012, 2013, 2014]; $.each(years, function(k, v){ var option = $('<option/>', {'value':v, 'text':v}) $('#year').append(option); }); }); </script> </head> <body> <select id="year"> <option>Year</option> </select> </body> </html>