rewrite menu ul li in #drupal
function convertToDropdown(elem){
$(elem).each(function() {
var list = $(this), select = $(document.createElement('select')).insertBefore($(this));
select.addClass('form-control i-made-this hidden-md hidden-lg');
list.addClass('hidden-xs hidden-sm')
$('>li a', this).each(function() {
var target = $(this).attr('target'),
option = $(document.createElement('option'))
.appendTo(select)
.val(this.href)
.html($(this).html())
.click(function(){
console.log('clicked');
// var url = $(this).val(); // get selected value
// if (url) { // require a URL
// window.location = url; // redirect
// }
// return false;
});
});
// list.remove();
$('select.i-made-this option').each(function(){
if($(this).val() == window.location.href){
$(this).attr('selected', true);
}
})
});
$('select.i-made-this').change(function(){
var url = $(this).val(); // get selected value
if($(this).val() != window.location.href){
window.location = url; // redirect
}
});
}
convertToDropdown('.shop-block-menu ul.nav');