I\'m trying to convert (with jQuery) a multi-level UL into a SELECT dropdown with the nested UL group being wrapped in OPTGROUPS
UL
SELECT
OPTGROUPS
Something simple solution for this
var markUp = [""], $li, $a; $("#sitemap > li").each(function(){ $li = $(this); if($li.find(">li").length){ markUp.push(""); $li.find(">li").each(function(){ $a = $(this).find("a"); markUp.push(""+$a.text()+"") }); markUp.push(""); } else{ $a = $li.find("a"); markUp.push(""+$a.text()+"") } }); markUp.push(""); $("#sitemap").replaceWith(markUp.join('')); $("#sitemap").change(function(){ window.location = $(this).val(); });