Make select option selected based on an unordered list using jQuery
问题 I've converted my unordered list into a select option list, however I'm not sure how can I make the 'selected' attribute added the option which correlates to the same hyperlink in the list. Mark-up <div class="navigation"> <ul> <li><a href="foo.html">Foo</a></li> <li><a href="bar.html" class="selected">Bar</a></li> <li><a href="boo.html">Boo</a></li> </ul> </div> Javascript $('<select />').appendTo('.navigation'); // Populate dropdown with menu items $('.navigation ul a').each(function() {