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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:02:15+00:00 2026-05-23T03:02:15+00:00

EDIT: Seems i didnt use an ‘id’ on my textarea, so that problem has

  • 0

EDIT: Seems i didnt use an ‘id’ on my textarea, so that problem has cleared up but i’m still getting a few problems with text()

var e = $('textarea#cost-'+i).val(); // e = 1 (for first iteration)
alert($('p#subtotal-'+i).text()); // alert 'subtotal' which is the text in my p#subtotal-1
$('p#subtotal-'+i).text().replaceWith(e); // <- this is the problem, i think
alert($('p#subtotal-'+i).text()); // no alert box at all

and this time i made sure they all have ids.


The following code, generates an alert box with nothing in it.
If i change it to val() it says ‘undefined’


$('textarea.costbox').live('blur',function() {
for(var i in items) {
alert('iteration '+i);
alert('textarea#cost-'+i);
var e = $('textarea#cost-'+i).text();
alert('cost '+e);
}
});

<textarea name="cost-1" class="costbox"></textarea>

The idea for this code is to update a subtotal when the value has been changed.
This is the last piece of the puzzle.

All the HTML looks normal when i inspect it in chrome. And all the rest of my code is working fine.

This should be running with modernizer1.7 and jQuery1.5.1, based off recent HTML5Boilerplate.

Here’s another example of the same basic thing – http://jsbin.com/obeho5/3/edit

Its probably something simple but i’ve been stuck here for hours and can’t see it.

[if its not something obvious and simple i can post more code]

  • 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-23T03:02:16+00:00Added an answer on May 23, 2026 at 3:02 am
    $('textarea#cost-'+i).text();
    

    Is looking for a textarea with an ID, you’ve given it a name, you need to do:

    $('textarea[name="cost-' + i +'"]').text();
    

    edit: for your updated issue:

    $('p#subtotal-'+i).text().replaceWith(e); 
    

    should be

    $('p#subtotal-'+i).text(e);
    

    You don’t need to worry about replaceWith, you can simply add the new text as a parameter of the method.

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

Sidebar

Related Questions

Edit: From another question I provided an answer that has links to a lot
I'm some trouble finding the problem with my program. Getting the error: Use of
EDIT: It seems to be something with having the two queues in the same
Is the documentation for Rich Edit Controls really as bad (wrong?) as it seems
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
EDIT: now the question becomes, how do I tell Sajax to use POST instead
I am having problems getting a function that clicks all search matched checkboxes. The
Sorry for what seems like a silly question: But I've never, ever worked with
java accepts -Xmx1k happily as an argument, but experiments show this is still really
I run into what seems to be a very classical problem: An item and

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.