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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:02:30+00:00 2026-06-10T14:02:30+00:00

Is there a way with javascript (particularly jQuery) to find an element based on

  • 0

Is there a way with javascript (particularly jQuery) to find an element based on a partial attribute name?

I am not looking for any of the selectors that find partial attribute values as referenced in these links:

  • starts with [name^=”value”]
  • contains prefix [name|=”value”]
  • contains [name*=”value”]
  • contains word [name~=”value”]
  • ends with [name$=”value”]
  • equals [name=”value”]
  • not equal [name!=”value”]
  • starts with [name^=”value”]

but more something along the lines of

<div data-api-src="some value"></div>
<div data-api-myattr="foobar"></div>

and

$("[^data-api]").doSomething()

to find any element that has an attribute that starts with “data-api”.

  • 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-10T14:02:31+00:00Added an answer on June 10, 2026 at 2:02 pm

    Not sure what it is you’re looking for, but just spent a few minutes writing this:

    $.fn.filterData = function(set) {
        var elems=$([]);
        this.each(function(i,e) {
            $.each( $(e).data(), function(j,f) {
                if (j.substring(0, set.length) == set) {
                    elems = elems.add($(e));
                }
            });
        });
        return elems;
    }
    

    To be used like :

    $('div').filterData('api').css('color', 'red');
    

    And will match any elements with a data attribute like data-api-*, and you can extend and modify it to include more options etc. but of right now it only searches for data attributes, and only matches ‘starts with’, but at least it’s simple to use ?

    FIDDLE

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

Sidebar

Related Questions

Using only JavaScript and framework like dojo/jQuery... Is there a way to find the
Is there a way in JavaScript to select a element of a multidimential array.
Is there a way in JavaScript or jQuery to call a function when the
is there a way with javascript/jquery to prevent images from loading? I am building
Is there any way to load JavaScript from public folder before JavaScript-files from assets/javascript
I'm trying to figure out if there is a way (using JavaScript, or jQuery
Is there an way to delete everything after a particular div with javascript/jquery and
Recently I have been looking at jquery/javascript solutions to emulating the placeholder attribute, but
Is there a way in JavaScript to compare values from one array and see
Is there a way in JavaScript for me to tell whether a resource is

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.