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

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -