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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:48:28+00:00 2026-05-21T07:48:28+00:00

If I have an HTML element <input type=submit value=Search /> a css selector needs

  • 0

If I have an HTML element <input type="submit" value="Search" /> a css selector needs to be case-sensitive:

input[value='Search'] matches

input[value='search'] does not match

I need a solution where the case-insensitive approach works too. I am using Selenium 2 and Jquery, so answers for both are welcome.

  • 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-21T07:48:29+00:00Added an answer on May 21, 2026 at 7:48 am

    It now exists in CSS4, see this answer.

    Otherwise, for jQuery, you can use…

    $(':input[name]').filter(function() {
       return this.value.toLowerCase() == 'search';
    });
    

    jsFiddle.

    You could also make a custom selector…

    $.expr[':'].valueCaseInsensitive = function(node, stackIndex, properties){
         return node.value.toLowerCase() == properties[3];
    };
    
    var searchInputs = $(':input:valueCaseInsensitive("Search")');
    

    jsFiddle.

    The custom selector is a bit of overkill if doing this once, but if you need to use it many times in your application, it may be a good idea.

    Update

    Is it possible to have that kind of custom selector for any attribute?

    Sure, check out the following example. It’s a little convoluted (syntax such as :input[value:toLowerCase="search"] may have been more intuitive), but it works 🙂

    $.expr[':'].attrCaseInsensitive = function(node, stackIndex, properties){
        var args = properties[3].split(',').map(function(arg) {
            return arg.replace(/^\s*["']|["']\s*$/g, '');  
        });
        return $(node).attr(args[0]).toLowerCase() == args[1];
    };
    
    var searchInputs = $('input:attrCaseInsensitive(value, "search")');
    

    jsFiddle.

    You could probably use eval() to make that string an array, but I find doing it this way more comfortable (and you won’t accidentally execute any code you place in your selector).

    Instead, I am splitting the string on , delimiter, and then stripping whitespace, ' and " either side of each array member. Note that a , inside a quote won’t be treated literally. There is no reason one should be required literally, but you could always code against this possibility. I’ll leave that up to you. 🙂

    I don’t think map() has the best browser support, so you can explictly iterate over the args array or augment the Array object.

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

Sidebar

Related Questions

CSS : form input:not([type='button']),form input:not([type='submit']) { width: 200px } HTML : <form> <input type='button'
I have an HTML input element of type select. The height of the element
I have 3 elements and one form with a button: <input type=submit value=Follow All
I have a html element (like select box input field) in a table. Now
I have an HTML form generated by JSF which maps an input element to
I have a via with some jQuery function to get value from HTML element
Does the HTML select element have an on select event? what exactly is the
I have following HTML with two elements having the same name <input type=hidden name=
I have some question. I have the html form with one hidden input element.
I have HTML page with some HTML element with ID=logo . I need to

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.