Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is this jQuery selector: a[@rel*=lightbox]?

I am doing a bit of refactoring on some logic and i came across this chunk of code and i am still trying to understand it

  try {
   $('a[@rel*=lightbox]').lightBox(); 
  } catch (e) {}

I understand the try catch part but what is this part

('a[@rel*=lightbox]')
like image 653
Matt Elhotiby Avatar asked Jan 24 '11 01:01

Matt Elhotiby


2 Answers

It is the old XPath way of saying find anchors with lightbox in their rel attribute. So it would match an anchor like the example below...

<a href="http://example.com/image.jpg" alt="image" rel="external me lightbox">Link</a>

It has been deprecated and removed from new versions of jQuery. To get it to work with the latest versions, just drop the @:

$('a[rel*=lightbox]')
like image 61
alex Avatar answered Oct 06 '22 01:10

alex


This is an Atrribute Contains selector using deprecated @ (XPath) syntax.

like image 43
SLaks Avatar answered Oct 06 '22 01:10

SLaks