As a complete newbie to JavaScript, I've come across similar questions but I'm lost when it comes to coding - help needed! So here's the code I have so far, and I'm hoping someone can assist me.
Currently, I have JavaScript set up to show and hide a div based on its ID, but I want to modify it to work with Class names instead. I have multiple classes that I need to toggle visibility for by clicking a button. This is for a Masterlist of Trans* characters roleplayed on Tumblr, where I want the ability to filter and display specific categories of characters with ease (like MtF trans characters only).
Here's the JS snippet I currently have. Any suggestions on how to adapt this for classes would be greatly appreciated!
<script>
function myFunction1() {
var x = document.getElementById('all');
if (x.style.display === 'block') {
x.style.display = 'none';
} else {
x.style.display = 'block';
}
document.getElementById("mtf").style.display = "block";
document.getElementById("ftm").style.display = "block";
document.getElementById("nonbinary").style.display = "block";
document.getElementById("fluidqueer").style.display = "block";
}
</script>
<script>
// Additional functions for other class toggles...