counting visible divs with class name jquery
Pretty sure you need to do $(".level1:visible").length;
the Space is breaking the code
$(".level1 :visible")
is a descendant selector: you are selecting all visible elements that are descendants of .level1
. There are three div
elements that are visible beneath .level1
elements.
Use this instead:
$(".level1:visible").length;
See your fiddle per my update.