4 ms·
> Gotta love that "modern" triple attribute repetition. You can golf it down a bit: el.style.display=el.style.display == 'none' ? '' : 'none';
by mschuster91 3y ago
> Gotta love that "modern" triple attribute repetition.
You can golf it down a bit:
el.style.display=el.style.display == 'none' ? '' : 'none';
- anakaine 3y agoEven though I can appreciate the elegance of your solution, I'd prefer the former for clarity.
- OJFord 3y agoSurely el.style.display = el.style.display ? 'none' : '' (after toggling we've already obliterated any possible third value for it anyway, doesn't seem significant)
- Finbarr 3y agoOf course. Because that's infinitely better than: $(el).toggle();