Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:54:18+00:00 2026-05-17T00:54:18+00:00

I have an Array of CSS selectors I want to find if an Element

  • 0

I have an Array of CSS selectors

I want to find if an Element has at least one of the CSS selectors

Example:

var selectors = ['green', 'red', 'yellow']

<div id="elem1" class="red purple yellow white"></div>
<div id="elem2" class="black white"></div>

my function should return true on elem1 and false on elem2

I use prototypejs 1.7_rc2

Thanks for your insights

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:54:19+00:00Added an answer on May 17, 2026 at 12:54 am
    function matchesSomeSelectors(element, selectors) {
       return selectors.some(function (selector) {
           return Prototype.Selector.match(element, selector);
       }); 
    }
    

    http://jsfiddle.net/4p4LJ/

    I’m not sure if some is available in IE or older browsers, but you can easily replicate it yourself if needed.

    Here’s Mozilla’s implementation if you want it:

    if (!Array.prototype.some)
    {
      Array.prototype.some = function(fun, thisp)
      {
        var i = 0,
            len = this.length >>> 0;
    
        if (typeof fun != "function")
          throw new TypeError();
    
        var thisp = arguments[1];
        for (; i < len; i++)
        {
          if (i in this &&
              fun.call(thisp, this[i], i, this))
            return true;
        }
    
        return false;
      };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have array unknown size i want to transfer to matrix[n][2].Example; D[c]=1,2,3,4,5 D[c/2][2]= 1
I have an array of selectors like : var arr = [.discuss .title .post,
How would one return a class computed CSS property/property array? Like, if I have
Let's say I have an array of objects [{href: 'some_uri', 'class': 'this-css-class'}, {href: 'another_uri',
I have array of strings, String[] data and it's 10 elements has value P
I have an array like this: var gridArray = [ 1,2,0,1,2,3,2,1,2,3,4,4,3,2,2,2,0 ] And I
I have the code below: $(document).ready(function() { var bgimages=new Array() bgImages[0]=bg.jpg bgImages[1]=bg2.jpg //sloppy preload
I have two example filename strings: jquery.ui.min.js jquery.ui.min.css What regex can I use to
I have an array $eps coming from MYSQL table and I want to output
I have an element with multiple classes and I'd like to get its css

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.