Struggling with a seemingly simple function for way too long now. The task is to show a hidden div with information on an item when it's clicked, without using jQuery. Tried multiple examples from various sources but nothing seems to work. Hoping for a straightforward solution before going crazy. Any suggestions?
JS:
var div = document.getElementById('show')
var beer = document.getElementById('beer')
function show_div() {
if (div.style.display == "none") {
div.style.display = ""
} else {
div.style.display = "none"
}
};
CSS
div { display: none; }
HTML
<li>Beers I Currently Have
<ul>
<li><a href="#" id="beer" onclick="show_div">2 Sierra Nevada Bigfoot (12/11/14)</a></li>
<div id="show">Delicious barley wine that has been aging in my cellar for nearly 2 years now.</div>
....