Help me with this function

d9esco

Solid State Member
Messages
9
Location
america
Im trying to get a display: none style to change from none to block on multiple divs using a single function. It only works on the first div. How can I get this to work?

function show(name) {
var e = document.getElementsByClassName(name);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}

<html>

<p onclick="show('li')">Click here</p>

<ul class='li'>
<li>
</ul>

<ul class='li'>
<li>
</ul>
 
Back
Top Bottom