javascript - How to convert a select dropdown into an ul dropdown? -
i'm trying convert select dropdown ul can create bootstrap button display ul allowing list items act options.
<select id="sortfield" onchange="refreshpage('{$pagebase}','{$searchterm}', '{$pagenumber}', '{$currentfacet}')"> <option value="default"> sort </option> <option value="relevance">relevance</option> <option value="highest rated">highest rated</option> <option value="best sellers">best sellers</option> <option value="new arrivals">new arrivals</option> <option value="lowest price">lowest price</option> <option value="highest price">highest price</option> </select>
the jquery function convert select is:
var ul = $('<ul/>'); $("#sortfield option").each(function() { $('<li/>').val(this.value).text(this.text).attr('onchange', $("#sortfield").attr("onchange")).appendto(ul); }); $("#sortfield").replacewith(ul);
hope that's help
bye
Comments
Post a Comment