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

  • Home
  • SEARCH
  • 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 9168233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:34:54+00:00 2026-06-17T15:34:54+00:00

I was thinking if there is a way to find if element’s attribute contains

  • 0

I was thinking if there is a way to find if element’s attribute contains a specified value. The attribute is unknown. If I have this HTML:

    <input class="first" type="checkbox" data="THE-VALUE" />
    <input class="second" type="checkbox" />
    <input class="third" type="checkbox" name="THE-VALUE" />

I want to find all the inputs that has attribute with value THE-VALUE (in this case .first and .third). I don’t need solution for this case where inputs are 3, but if I have 50 inputs and the attributes containing THE-VALUE are all different. I have tried things like .attr(':contains("THE-VALUE")') and $('input[="THE-VALUE"]'), but by obvious reasons it doesn’t work.

So my question is .. is there any way to find that ?

  • 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-17T15:34:55+00:00Added an answer on June 17, 2026 at 3:34 pm
    $("input").filter(function() {
        return $.grep(this.attributes, function(arg) {
            return arg.nodeValue === "THE-VALUE";
        }).length > 0;
    }).prop("checked", true);
    

    DEMO: http://jsfiddle.net/7tsZN/


    Or as a selector extension:

    $.expr[':'].hasattrval = function(e, i, p) {
        return $.grep(e.attributes, function(arg) {
            return arg.nodeValue === p[3];
        }).length;
    };
    
    $("input:hasattrval('THE-VALUE')").prop("checked", true);
    

    DEMO: http://jsfiddle.net/7tsZN/1/

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

Sidebar

Related Questions

This is probably just wishful thinking... Is there any way to check to see
is there a way to find out the value in the cell before and
I have this if(noDelay){ $(element).find(. + options.class).remove(); } else { $(element).find(. + options.class).fadeOut().remove(); }
I'm thinking if there's a way (a component or reference) to breakdown an adodb.recordlist
I'm thinking if there is a way to use javascript to pick up ANY
I've been thinking for a while if there's a way to get cross-domain AJAX
This might seem as silly question but I am thinking there might be the
I've been thinking of implementing this system, but can't help but feel there's a
Is there a somewhat standardized way to semantically mark up citations in HTML? I
I cant seem to find a way to do this. Some guidance would be

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.