JSFiddle - React, Tailwind, and code Playground

by ChrisStanyon

HTML

<button onclick="filter('test')">
Test
</button>
<button onclick="filter('exclude')">
Exclude
</button>

<div class="test filter">
This is a test
</div>
<div class="test filter exclude">
This is a test
</div>
<div class="test filter">
This is a test
</div>

JavaScript

function filter(c) {

if (c == "exclude") {
    x = document.querySelectorAll('.filter:not(.exclude)');
} else {
    x = document.getElementsByClassName("filter");
}
console.log(x);

}