Is there a css parser within js?
like F(“#a”) will return me the element with id a.
F(“.asd”) will return me the elements belonging to class asd
F(“p#g”) will return me the p element with id g.
F(“p”) will return me all the p elements
etc etc
i mean i know we can probably hand-code all the rules ourselves but there got to be a better way around that right?
You can use
document.querySelector()and/ordocument.querySelectorAll(), but it doesn’t have the best browser support, thanks to IE.For better browser support, use SizzleJS, the selector engine in jQuery. It will use
querySelectorAll()where supported.