Is there a way to convert a drop down menu to be a list using jquery... so:
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
to
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
Thanks
Just iterate over the <option>
elements and create a corresponding <li>
for each, then add them to a <ul>
, like this: (where #menu
is the ID of your drop-down)
var list = $('<ul>');
$('#menu option').each(function() {
$('<li>').text($(this).text()).appendTo(list);
});
list.appendTo($('body'));
Working example on JSBin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With