Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

document.querySelectorAll() uses the same kind of syntax for selectors as jQuery.


And requires IE 9+ which rules it out for a lot of people...


Actually, no. IE8 supports it.

http://caniuse.com/queryselector


IE8 is limited to the old CSS selectors so basically it sucks and doesn't really support it.


In practice, especially for javascript usage, the old CSS selectors cover all the bases.

The new-stuff, while great for styling, isn't all that relevant for scripting. nth-child, say, is often (though not always) simply an indexing operation on the return value of querySelectorAll; and in general you don't even want that since usually you have a specific element in mind and have labelled that element with a class to find it.

I don't support IE8 anymore, and use CSS3 liberally in the actual css, yet I can't think of more than a handful of cases I used the selectors from javascript, certainly none of them critical. Do you actually use this?


But so is all of the actual CSS in your app.


and support only a limited subset of the selectors jQuery supports.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: