Skip to content

Instantly share code, notes, and snippets.

@cognominal
Created February 12, 2020 17:56
Show Gist options
  • Select an option

  • Save cognominal/e4be65d3c21a88f4d13013bf1137439b to your computer and use it in GitHub Desktop.

Select an option

Save cognominal/e4be65d3c21a88f4d13013bf1137439b to your computer and use it in GitHub Desktop.
menu
<script>
function menu_display(v) {
console.log('display ' + v)
let elt = document.querySelector('.menu')
elt.style.display = v;
console.log(elt.style.display)
}
function popup_menu() {
console.log('coucou')
let elt = document.querySelector('.menu')
console.log(elt)
elt.style.display = 'block';
}
function menu_select(i) {
console.log('menu_select ' + i)
menu_display('none')
}
let menu = ['entry 1', 'entry 2']
</script>
<div class='menu_container' onclick="popup_menu()">
coucou
<div class='menu'>
<div onclick="menu_select(1)">tutufff 1</div>
<div onclick="menu_select(2)">tutufff 2</div>
</div>
</div>
<style>
.menu {
border: solid 1px black;
display: none;
position: absolute;
top: 0px;
left: 0px;
background-color: white;
opacity: 1
}
.menu_container {
position: relative;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment