/* This is the class turned on/off by the JS */
.hide {
visibility: hidden;
}
#green, #red {
/* Forces the dots to stack */
width: 11px;
/* Puts the stacks of dots side-by-side */
float: left;
/* Adds some whitespace between dot stacks */
padding: 0 4px;
}
JavaScript
function toggleHide(id) {
var element = document.getElementById(id),
className = "hide",
classString = element.className,
nameIndex = classString.indexOf(className);
if (nameIndex == -1) classString += ' ' + className;
else classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length);
element.className = classString;
}
// Pass in the ID of the element you want to
// toggle visibility of. You do have to call it
// multiple times to toggle multiple elements.
// IDs: red (all), r1, r2, r3, r4, r5, green (all), g1, g2, g3, g4, g5
toggleHide('g2');
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.