With this code I create a <select>
element:
$('ul.category-list').each(function () {
var list = $(this),
select = $(document.createElement('select')).insertBefore($(this).hide()).change(function () {
window.location.href = $(this).val();
});
$('>li a', this).each(function () {
var option = $(document.createElement('option'))
.appendTo(select)
.val(this.href)
.html($(this).html());
if ($(this).attr('class') === 'selected') {
option.attr('selected', 'selected');
}
});
list.remove();
});
How do I give the <select>
element an id or class so I can control it with CSS?