JSFiddle - React, Tailwind, and code Playground
by brigand
HTML
<section class="table">
foo
</section>
<section class="table">
bar
</section>
<section class="table">
baz
</section>
JavaScript
function qsa(sel, parent) {
return Array.prototype.slice.call((parent || document).querySelectorAll(sel));
}
function toggle(element) {
let {
display
} = getComputedStyle(element);
display = display === 'none' ? '' : 'none';
// Can remove these lines
let text = element.textContent.trim();
console.log('Checked display for', text);
const commit = () => {
// Can remove this line
console.log('Setting display for', text);
element.style.display = display;
}
return commit;
}
setInterval(() => {
qsa('section.table').map(toggle).forEach(commit => commit());
}, 1500)