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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:36:34+00:00 2026-05-19T00:36:34+00:00

I am trying to write line of jquery that finds an input that has

  • 0

I am trying to write line of jquery that finds an input that has a class that begins with “a\d” (the letter a and a number) and replace the number with another number.

This is what I have tried, does anyone notice why this would not work?

$('form').find('input[class^="a\d"]').replace(/a\d+/,'a22');

Please note: this is one line out of many, I have extracted this line because it is where I am having trouble.

  • 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-19T00:36:35+00:00Added an answer on May 19, 2026 at 12:36 am

    You’ll need to do it more like this:

    $('form').find('input[class^="a"]').attr('class', function(i,cls) {
        if( /a\d/.test( cls ) ) {
            return cls.replace(/a\d+/,'a22');
        }
    });
    

    When using .attr() to set the class (or any attribute), you can pass it a function which has 2 parameters. The i is the current index in the iteration. The cls is the current value of class.

    The return value will be used to update the class. If nothing is returned, nothing will be changed.

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

Sidebar

Related Questions

I'm trying to write a replacewith function in jQuery that will replace specific words
I am trying to write a small Mac command line app that can read
I am trying to write a text viewer widget with PyGTK that displays line
I am trying to write some code that that will draw the line which
Newbie C++ programmer here. I'm trying to write a command line application that takes
I'm trying to remove the 'ui-btn-active' class from this JQuery Mobile markup piece: <a
I'm trying to write out the specific line of code that contains the IF
Im trying to write a JQuery wrapper extension that takes a content div and
I'm trying to write a line in Bash that gets the Content-Type (without encoding)
Well, I am trying to write a line of information to log in a

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.