Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-20-2022, 07:32 PM   #1
Registered: Jan 2012
Posts: 87

Rep: Reputation: Disabled
Question CSS: How to create an Attribute Selector with Multiple Values?

I want to select links whose "data-url" attribute contains at least one of 4 values.

I have tried this:

a[data-url*="fandom" "deviantart" "anime" "furry" i]
I've also tried it with commas between the quoted values and with | between the quoted values. None of them work.

Do I need to write a separate selector for each value?

I've also tried reading through the W3c and mozilla developer docs; this doesn't seem to be covered.

Last edited by starkid; 09-20-2022 at 08:05 PM. Reason: added info
Old 09-21-2022, 09:01 AM   #2
Senior Member
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,554

Rep: Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526Reputation: 2526
Originally Posted by starkid View Post
I want to select links whose "data-url" attribute contains at least one of 4 values.
You can't do that with a single selector.

To select elements where ANY of those match you need four separate selectors (which are themselves comma-separated), i.e:
a[data-url*="fandom"] , a[data-url*="deviantart"] , a[data-url*="anime"] , a[data-url*="furry"]
To select ALL of them, filter the attribute multiple times:

However, depending on the context, beware that such simple keyword searching may select more than is intended - not every instance of the five characters "anime" is going to be refer to Japanese animation, the word "accompaniment" being one example.




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to create a new Attribute in OpenLDAP and map it with existing attribute kovvuri Linux - Kernel 1 02-19-2020 01:43 PM
[SOLVED] ldap_add undefined attribute type (17) additional info attribute type undefined yashfire007 Linux - Newbie 6 03-20-2015 10:12 AM
How do I modify 1 of my ldap attribute if I have 2 same attribute under 1 entry? chinho Programming 1 01-31-2011 04:37 AM
update problem "Attribute error object has no attribute 'rsplit' ruse Linux - Newbie 0 08-28-2009 02:46 AM
ldap_add: Undefined attribute type (17) additional info: ojectclass: attribute type vinaytp Linux - Newbie 2 05-28-2009 05:57 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration