/* When the user clicks on the button,
closes every dropdowns and open the only one passed as argument */
/* Javascript only */
function myFunction(element) {
var dropdowns = document.getElementsByClassName("dropdown-content");
// element.nextSibling is the carriage return… The dropdown menu is the next next.
var thisDropdown = element.nextSibling.nextSibling;
if (!thisDropdown.classList.contains('show')) { // Added to hide dropdown if clicking on the one already open
var i;
for (i = 0; i < dropdowns.length; i++) {
dropdowns[i].classList.remove('show');
}
}
// Toggle the dropdown on the element clicked
thisDropdown.classList.toggle("show");
}
/* W3Schools function to close the dropdown when clicked outside. */
window.onclick = function(event) {
if (!event.target.matches('.dropbtn') && !event.target.closest('.formParent')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
//CHECKBOX FUNCTIONALITY START
var isChecked = false;
function checkAll() {
var checkboxes = document.getElementsByClassName('chkBox');
if (isChecked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
isChecked = !isChecked;
}
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.