I have a help page with a bunch of javascript toggles to show or hide help for the topic. Is there a way to toggle them all to show all or hide all?
<a href="javascript:toggle('roles');">Roles or Account Permissions</a>
<div id="roles" style="display:none">
<a href="javascript:toggle('tracks');">Tracks and Activities</a>
<div id="tracks" style="display:none">
<a href="javascript:toggle('password');">Modifying Password</a>
<div id="password" style="display:none">
Like maybe
<a href="javascript:toggle('roles', 'tracks', 'password');">Toggle all</a>
Here is my javascript
function toggle(divId) {
"use strict";
var div = document.getElementById(divId);
if (div.style.display === "none") {
div.style.display = "block";
} else {
div.style.display = "none";
}
}
Aucun commentaire:
Enregistrer un commentaire