Is querySelector supported by all browsers?

KoolKabin picture KoolKabin · Oct 4, 2010 · Viewed 13.6k times · Source

I would like to know is querySelector supported by all browsers? is not what's alternate for it to use?

I have tested it with IE8, FF3, Chrome 4. Its fine for me. I do not have old browsers. So i would like to know if old browsers will give problem to me or not?

Answer

annakata picture annakata · Oct 4, 2010

IE7< don't support it and IIRC IE8 has issues with namespaces. There's at least one more esoteric browser out there with major issues but I don't recall which it is.

Basically there is no unified expression-based DOM method, and absolutely your best bet is to use a library (the ubiquitous "use jquery" answer, but you should at least check out Sizzle if you have a problem with large libraries) because rolling your own is more effort than reasonably worthwhile (I speak from experience).