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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:19:46+00:00 2026-06-09T18:19:46+00:00

This is my text input box <input class=tb id=tb43[0] type=text size=30 maxlength=200 /> When

  • 0

This is my text input box

<input class="tb" id="tb43[0]" type="text" size="30" maxlength="200" />

When cloning with jQuery I’d like the id of the new cloned box to be “tb43[1]”.

$clone.find(".tb").attr("id").replace(/\d+/, function (val) { return parseInt(val) + 1; });

This only increments the first number but how can I manage to increment the number in the square brackets?

Thanks

  • 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-09T18:19:48+00:00Added an answer on June 9, 2026 at 6:19 pm
    1. You can use .attr("id", function() {}) to change the ID. You’re currently not altering the ID.
    2. You can alter the regexp to match only in square brackets.
    3. You can use + instead of parseInt (the latter has some caveats).

    E.g.

    $clone.find(".tb").attr("id", function(i, id) {
      return id.replace(/\[(\d+)\]/, function(match, number) {
        // `number` refers to the first group (denoted with ())
        return "[" + (+number + 1) + "]";
      })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input box like the following: <input type=text value= somethingSpecial=filename.txt id=myID class=box>
So when I set the input like this example the text box, because it
I have a text input : <input type=text onkeydown=processText(this) /> I have a processing
I am using IE7. I have an input box as follows: <input name=location type=text
I have an html text box with some having class names as numbers <input
I have two input box: <input name=adrs id=adrs type=text> <input name=city id=city type=text> Now
I have a jquery template which renders pictures <script id=PictureList type=text/x-jquery-tmpl> <ul class=pictureList> <li
I have this input text and an input button...I am looking to have them
I have this input text and input button, I am trying to get them
Possible Duplicate: HTML Text Input allow only Numeric input I used this script function

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.