I see a few problems here. In no particular order:
- It would probably be safest to change the inner variable name
show
to something else since your function is also calledshow(...)
. - Declare variables with the
var
keyword to avoid populating the top namespace. - You're retrieving DOM elements by ID, but none of your DOM elements (in the above example) have ID attributes. You'll want to add them to your
li
items at least, e.g.id="1"
- If these elements don't have
visible
to start off with, you'll add bothvisible
andhidden
when you "toggle". - If you toggle
visible
andhidden
on theli
items, thennotShow = document.getElementsByClassName("visible")[0];
should probably change, as you will be retrieving theli
items once they havevisible
in them. Try using other class names or element types.
Here is a jsFiddle to get you started (ignore the window.show definition that's specific to jsFiddle).