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

I'm doing a bit of refactoring by some logic, and I stumbled upon this piece of code, and I'm still trying to figure it out.

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

I understand the try catch part, but what is this detail

('a[@rel*=lightbox]')
+5
source share
5 answers

This is an old XPath way of saying that find bindings with lightboxin their attribute rel. Thus, it will correspond to the anchor, as an example below ...

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

It is deprecated and removed from new versions of jQuery. To make it work with the latest versions, just release @:

$('a[rel*=lightbox]')
+12
source

Atrribute @ (XPath).

+2

There is a better way to write this selector.

$('img[rel="lightbox"]')

This will allow you to select any image tags with a lightbox relationship. You do not need to do a try statement, if you correctly included all your scripts, it should work fine.

+1
source

It selects all links containing a lightbox in the rel attribute

0
source

He is looking for links on the page that have some ability to launch a lightbox window.

0
source

All Articles