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 8542261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:01:14+00:00 2026-06-11T12:01:14+00:00

Is there a way to find all the elements with attributes that start with

  • 0

Is there a way to find all the elements with attributes that start with a particular string?

I am using Mootools framework and this is what I have tried:

$$('*[data-media-*]');

But it just outputs all the elements in the page.

So is there a way to get all the elements in the page that have attributes that start with, data-media-?

  • 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-06-11T12:01:15+00:00Added an answer on June 11, 2026 at 12:01 pm

    you can filter elements that you already have to return ones with matching data-* attributes.

    Elements.implement({
        filterData: function(substring){
            return this.filter(function(element){
                var attribs = element.attributes,
                    len,
                    ii = 0;
    
                for (len = attribs.length; ii < len; ++ii) {
                    if (attribs[ii].name.indexOf('data-') === 0 && attribs[ii].name.indexOf(substring) !== -1) {
                        return true;
                    }
                }
            });
    
        }
    });
    
    console.log($$("div").filterData('foo'));
    console.log($$("div").filterData('bar'));
    console.log($$("div").filterData('oba'));
    

    in action: http://jsfiddle.net/dimitar/pgZDw/

    downside: you already need to pass it on a collection of elements that make sense, eg. div.foo or #someid *

    a more elegant solution would be to add a :data() pseudo to Slick:

    (function(){
        // cache reusable string 
        var data = 'data',
            hyphen = '-',
            // set the fallback via XMLSerializer, if no outerHTML (eg. FF 2 - 10)
            XS = this.XMLSerializer && new XMLSerializer();
    
        Slick.definePseudo(data, function(value){
            return (this.outerHTML || XS.serializeToString(this)).test([data, value].join(hyphen));
        });
    }());
    
    
    console.log($$("div:data(foo)"));
    console.log($$(":data(media-)"));
    

    updated example: http://jsfiddle.net/dimitar/pgZDw/3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a better way to find all form elements in a Drupal form
I'm using rails 2.3.5 with i18n. I's there a way to find all not
Is there a way to create a condition like this? @products = Product.find(:all, :limit
Is there a way to find all clickable elements specified with either click() or
Is there a way to search elements based on data attributes? I have the
Is there an easy way or an html editor that can find all like-phases
Is there a better/faster way to find all elements with a class name in
is there a way to find all script files added to a page in
in visual studio 6 is there a way to Find All References. Don't see
Is there some way I can find all active spies in sinon.js? I'd like

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.