Re:What We Lost with PHP and jQuery
by luckylion on Sunday June 01, 2025 @12:44PM
(#44152156)
The one thing I really miss from jQuery is the fluent interface. $(".someclass").hide() and all of them are hidden. document.querySelectorAll(".someclass").forEach(e => e.style.display = "none") is a lot more verbose. $(".someclass").addClass("something else") translates to document.querySelectorAll(".someclass").forEach(e => {e.classList.add("something");e.classList.add("else");}) so now you either write your own mini-abstraction over DOM methods or use some framework, even if the things you want to do absolutely do not need it.
[ Parent
| on HN ]
Re:What We Lost with PHP and jQuery
by someothherguyy on Sunday June 01, 2025 @01:15PM
(#44152339)
classList.add is variadic, so a more honest implementation might be
var _ = s => document.querySelectorAll(s)
_('.someclass').forEach(e => {e.classList.add('something', 'else')})