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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:16:43+00:00 2026-06-03T06:16:43+00:00

The fallowing table has many identical text inputs… <table> <tr> <td> <a href=# id=plus><img

  • 0

The fallowing table has many identical text inputs…

<table>
  <tr>
    <td>
      <a href="#" id="plus"><img src="plus.png" width="12" height="12" /></a>
      <input type="text" value="0" />
      <a href="#" id="minus"><img src="minus.png" width="12" height="12" /></a>
    </td>
    .
    .

    <td>
      <a href="#" id="plus"><img src="plus.png" width="12" height="12" /></a>
      <input type="text" value="0" />
      <a href="#" id="minus"><img src="minus.png" width="12" height="12" /></a>
    </td>
  </tr>
</table>  

and the fallowing jQuery script should increment/decrement the value of its closet text input…

 $("#plus").click(function(){
   var text = $(this).next(":text");
   text.val(parseInt(text.val(), 10) + 1);
 });

$("#minus").click(function(){
   var text = $(this).prev(":text");
   aux.val(parseInt(aux.val(), 10) - 1);
 });

the problem is that the script only works fine on the first pair of links of the table, incrementing and decrementing the value of its closest text input by one, and the rest of the remaining pairs of links don’t change the value of its closest text input and whats even worse, the links propagate to the home/jthernandez/Desktop/test.html# url when they are clicked on.

I’m not really sure whats going on here but the idea is that each pair of +, – links changes the value of its next(), prev() text input respectively. Any suggestions would be great. 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-03T06:16:44+00:00Added an answer on June 3, 2026 at 6:16 am

    You are close. As others have mentioned, you cannot have the same ID more than once. IDs are unique, to IDentify a single element. JavaScript will only look until it finds one, and then stop. Classes are used to group common elements. Use a class and your code should work fine (minus a typo in your javascript):

    HTML:

    <td>
        <a href="#" class="plus"><img src="plus.png" width="12" height="12" /></a>
        <input type="text" value="0" />
        <a href="#" class="minus"><img src="minus.png" width="12" height="12" /></a>
    </td>
    

    JS (you have a typo in minus, creating text, but using aux):

    $(".plus").click(function(){
        var text = $(this).next(":text");
        text.val(parseInt(text.val(), 10) + 1);
    });
    
    $(".minus").click(function(){
        var text = $(this).prev(":text");
        text.val(parseInt(text.val(), 10) - 1);
    });
    

    Demo: http://jsfiddle.net/jtbowden/bfM9Z/

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

Sidebar

Related Questions

I have a product table that has a many-to-many relation to itself (using a
Say I have Table A that has many Table B's. Table B has only
I am new to HQL and have the following table relationships: Term has many
I have a table joining two models in a has many through relationship. Users
I am fetching records from my record table. record table has many columns tow
Consider the following table which has the fields - id (int) and date_created (datetime):
Imagine the following database: Table 'companies' has fields id, name and flagship_product_id. Table 'products'
my table has the following fields videos |id| |average| |views| now i select some
Table has the following info: date |vendor|sales|percent| -------------------------- 2009-03-03| 10 |13.50| 1.30 | 2009-03-10|
My SAMPLE table has the following five columns: sample_id (PK) (NUMBER) sampled_on (DATE) received_on

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.