4 ms·
It needs to be querySelectorAll, and you need to handle cases where it returns null as well.
by fenwick67 8y ago
It needs to be querySelectorAll, and you need to handle cases where it returns null as well.
- 9dev 8y agoDarn, that's what you get from typing on mobile. Ment to use querySelectorAll originally. But apart from null handling (which can be solved using `|| []`), what else would be lacking? I used a similar version of this for a few projects a while back, with some additional stuff for query context and ID selector -> getElementById I think, but that's basically it...
- fenwick67 8y agoIt definitely works, I've written `document.querySelectorAll(x)||[]` many times. If all you're doing is making a few simple queries, it works fine.