Last active
September 27, 2022 17:03
-
-
Save bhaireshm/c7c10c61a3b9fc3e673889b0d1f52eab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="div1 d-block"> | |
// div content | |
</div> | |
<div class="div2 d-none"> | |
// div content | |
</div> | |
<div class="div3 d-none"> | |
// div content | |
</div> | |
--------------------------------- | |
toggleDivs(['div2', 'div3']); // shows div2 and div3 | |
function toggleDivs(divName) { | |
if (divName && divName.length > 0) { | |
divName.forEach((c) => { | |
if ($(`.${c}`).hasClass('d-block')) { | |
$(`.${c}`).removeClass('d-block').addClass('d-none'); | |
} else { | |
$(`.${c}`).removeClass('d-none').addClass('d-block'); | |
} | |
}) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment