Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(".dropdown dt a").click(function(){ if($(this).hasClass("open")) { $(this).blur(); return false; } $(this).addClass("open"); $(this).closest(".dropdown").find("ul").animate({opacity: 'show', height: 'show'}, 'fast'); return false; }).blur(function() { $(this).removeClass("open"); $(this).closest(".dropdown").find("ul").animate({opacity: 'hide', height: 'hide'}, 'fast'); }); $(".dropdown dd ul a").click(function() { var text = $(this).html(); $(this).closest("dt").find("a").html(text); $(this).parents("ul").hide(); $(this).closest("select").val($(this).find("span.value").html()); return false; }); /* Fancy Dropdowns */ function FancyDropdowns(selector){ $(selector).each(function () { var source = $(this); var selected = source.find("option[selected]"); var options = $("option", source); var markup = '&lt;dl class="dropdown"&gt;'; markup += '&lt;dt&gt;&lt;a href="#"&gt;' + selected.text() + '&lt;span class="value"&gt;' + selected.val() + '&lt;/span&gt;&lt;/a&gt;&lt;/dt&gt;'; markup += '&lt;dd&gt;&lt;ul&gt;'; options.each(function () { markup += '&lt;li&gt;&lt;a href="#"&gt;' + $(this).text() + '&lt;span class="value"&gt;' + $(this).val() + '&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;'; }); markup += '&lt;/ul&gt;&lt;/dd&gt;'; markup += '&lt;/dl&gt;'; source.after(markup); source.hide(); }); } $(document).ready(function () { FancyDropdowns(".dropdown.fancy"); $(".dropdown dt a").click(function(){ if($(this).hasClass("open")) { $(this).blur(); return false; } $(this).addClass("open"); $(this).closest(".dropdown").find("ul").animate({opacity: 'show', height: 'show'}, 'fast'); return false; }).blur(function() { $(this).removeClass("open"); $(this).closest(".dropdown").find("ul").animate({opacity: 'hide', height: 'hide'}, 'fast'); }); $(".dropdown dd ul a").click(function() { var text = $(this).html(); $(this).closest("dt").find("a").html(text); $(this).parents("ul").hide(); $(this).closest("select").val($(this).find("span.value").html()); return false; }); }); &lt;/script&gt; &lt;style&gt; /* NICER DROPDOWNS */ .dropdown dd, .dropdown dt, .dropdown ul { margin: 0; padding: 0; } .dropdown dd { position: relative; } .dropdown a,.dropdown a:visited { color: #666; text-decoration: none; outline: none; } .dropdown a:hover { color: #e85326; } .dropdown dt a:hover { color: #e85326; } .dropdown dt a { background: #fff url("dropdown-arrow.png") no-repeat scroll right center; display: block; border: 1px solid #666; width: 160px; padding: 5px; } .dropdown dt a span { cursor: pointer; display: block; } .dropdown dd ul { background: #fff none repeat scroll 0 0; border: 1px solid #666; color: #666; display: none; left: 0; position: absolute; top: 2px; width: auto; min-width: 170px; list-style: none; padding: 5px 0; } .dropdown dd ul li a { display: block; padding: 5px; } .dropdown dd ul li a:hover { background-color: #333; } .dropdown img.flag { border: none; vertical-align: middle; margin-left: 10px; } .dropdown span.value,.flagvisibility { display: none; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;select name="myselect-id" class="dropdown fancy"&gt; &lt;option selected="selected" value="25"&gt;Test 25&lt;/option&gt; &lt;option value="26"&gt;Test 26&lt;/option&gt; &lt;option value="27"&gt;Test 27&lt;/option&gt; &lt;option value="28"&gt;Test 28&lt;/option&gt; &lt;option value="29"&gt;Test 29&lt;/option&gt; &lt;option value="30"&gt;Test 30&lt;/option&gt; &lt;/select&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload