Skip to content

Instantly share code, notes, and snippets.

@takimo
Created March 4, 2011 01:16
Show Gist options
  • Save takimo/853971 to your computer and use it in GitHub Desktop.
Save takimo/853971 to your computer and use it in GitHub Desktop.
How to select of hidden selectElement
<a href="javascript:void(0);">menu</a>
<select style="display:none">
<option value="home">home</option>
<option value="about">about</option>
</select>
<script>
var select = document.querySelector("select")
document.querySelector("a").addEventListener('click', function(){
select.style.display = "";
select.focus();
select.style.display = "none";
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment