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

The Archive Base Latest Questions

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

I’ve got an input with a class name of .aa_ant that contains the value

  • 0

I’ve got an input with a class name of .aa_ant that contains the value 1.

Now, when I’m loading the page I’m doing this (CASE 1):

alert($('.aa_ant[value*=1]').length )

it outputs 1 as expected.

Now, I’m changing it to (CASE 2):

alert($('.aa_ant[value*="1"]').length )

It stops working. Also, if I change the 1 to a it also stops working (both CASES 1 and 2).

What I am doing wrong?

Update: the .aa_ant is a knockout control:

<input  class='aa_ant' data-bind='value: aa_ant, readOnly: is_readonly' />

Could that be a problem ?

Update: With the length property I want to see if there are any input elements that contain that value (I don’t want any elements to have that value). Also, I know that I could get all .aa_ant elements and enumerate through them to see if anyone contains the value but I’d like to do it jquery-ish.

Update:
Here’s the actual solution for reference:

if($('.aa_ant').filter(function(index) {
    if(this.value.indexOf("1") >=0) {
        return true ;
    }
    return false ;
}).length>0 ) {
    alert("Error");
}

Thanks for the help !

  • 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-17T16:34:40+00:00Added an answer on June 17, 2026 at 4:34 pm

    Your control doesn’t appear to have a value attribute. A CSS attribute selector won’t be able to read an attribute of an element if it isn’t set in the markup, that’s why it fails.

    This is a case of jQuery not actually complying exactly with the CSS spec as advertised. The only reason why [value*=1] works regardless is because it’s not a valid CSS selector, so in modern browsers it skips the browser’s native Selectors API and uses jQuery’s selector engine instead, which does support unquoted numbers and can return based on the value property, even though the value attribute doesn’t appear in the markup, so you get the expected result. The other selectors [value*="1"], [value*=a] and [value*="a"] are all valid CSS, but won’t match your control because it doesn’t have a value attribute in the markup, so you get no results.

    If you need to query an input control by its actual value, see if you can identify it by something else (does Knockout.js give it an ID?), otherwise you have to do some DOM traversal or filtering, and using .val() to check its value in order to get the correct element. Selectors should only be used for querying based on static attributes (i.e. attributes that don’t usually change in value), not for dynamic ones like value for input elements.

    A quick example using .filter() and .val():

    $('.aa_ant').filter(function() { return $(this).val().indexOf('1') >= 0; });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small

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.