Borgar.net

— Jump to the navigation index

miðvikudagur, 5. ágú 2009

CSS :target

jQuery (or Sizzle) supports :target in browsers where it runs querySelectorAll to handle the work. In older browsers, it doesn’t offer fallback support. I guess that this is simply because :target is such an uncommon selector?

I have no idea why you would want to use it, but because I have this selector extension and nowhere to put it, here it is:

jQuery.expr[':'].target = function ( a, h ) {
  return (a.id && (h = document.location.hash) && h === '#' + a.id)
};

Updated 6. aug. 2009: Optimized by @maranomynet

Published: 5. 8. 2009 23:24. Tagged: , , , .