开发者

How to select these elements

开发者 https://www.devze.com 2023-03-11 04:54 出处:网络
I\'d like to handler all elements with the attribute rel inside of an a elemen开发者_运维百科ts that start with string lightbox.

I'd like to handler all elements with the attribute rel inside of an a elemen开发者_运维百科ts that start with string lightbox.

How can I do it with jQuery?


With the attribute-starts-with selector:

$('a [rel^="lightbox"]')


you need startswith selector

 $('a[rel^="lightbox"]')


Use the attribute starts with selector.

$('a [rel^="lightbox"]')

EDIT: having re-read your question, it sounds like this may be what you want:

$('a[id^="lightbox"] [rel]')

This selects all elements that have the attribute rel and are within an a tag that has an ID starting with lightbox.


Just to be different... if it is a prefix (i.e. "lightbox-") you can use the |= selector.

$('a[rel|=lightbox]')
0

精彩评论

暂无评论...
验证码 换一张
取 消