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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:25:46+00:00 2026-06-15T16:25:46+00:00

I have the following rendered html: <table width=420 cellspacing=0 cellpadding=3 border=0> <tbody> <tr><td>….</td> </tr>

  • 0

I have the following rendered html:

<table width="420" cellspacing="0" cellpadding="3" border="0">
<tbody>
<tr><td>....</td>
</tr>
<tr>
<td>Total Amount Due:</td>
<td>$168.88</td>
</tr>

My final goal is to obtain and change the value shown after Total Amount Due. I have started by trying to select the element containing the text “Total Amount Due:”.

Here is my code attempting this:

var tdElement = $("td:contains('Total Amount Due:')");
alert($(tdElement).text());

I have tried changing the syntax a bit in the command line of Firebug, but when I do I always end up receiving an error in the first line. With the code like this, I do not receive an error until the second line where I get a TypeError: $(tdElement) is null.

Also, not sure if this affects anything but this table is actually within two other tables.

  • 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-15T16:25:47+00:00Added an answer on June 15, 2026 at 4:25 pm

    I get a TypeError: $(tdElement) is null.

    Even if it doesn’t match anything, jQuery returns a valid jQuery object (containing no matching elements), not null, so that sounds like either:

    • You don’t have jQuery loaded. Check the JavaScript console to see whether you have load errors and resolve any you find.

    • Or you do have it loaded, but you also have another library like Prototype or MooTools loaded that has stolen the $ symbol. If so, you have three choices (at least):

      1. Try to stop using the other library, and remove it from the page.

      2. Use jQuery instead of $ everywhere you want to use jQuery.

      3. Or put your jQuery code in a function you can use to shadow the $ symbol, like this:

        // If you have another library loaded, out here $ may not === jQuery
        (function($) {
            // Here, your code can happily assume $ === jQuery...
        })(jQuery);
        

    Once you sort that out:

    I’d strongly recommend not using :contains if the page is of any size. Instead, if that element is unique on the page, use an id and find it using $("#theid"). If not, use a class, and find it using $(".theclass").find(":contains('Total Amount')").

    And finally: You’re using

    var tdElement = $("td:contains('Total Amount Due:')");
    

    but then also

    alert($(tdElement).text());
    

    There’s no need to call $ a second time, just use the first jQuery instance:

    alert(tdElement.text());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following HTML table is rendered to my browser.I am creating this
I have the following CSS and HTML snippet being rendered. textarea { border:1px solid
I have the following table template that is rendered through knockout: <table class=gv data-bind=visible:
I have the following rendered HTML: <div id=ordersBrowseForm:ordersBrowseWestPane class=ui-layout-west ui-widget-content ui-corner-all ui-layout-pane ui-layout-pane-west data-combinedposition=west
I have the following element which specifies the size=15. However the rendered element, which
I have the following template in Backbone, all gets rendered perfectly. <a href=#list data-role=button
I have a simple model forms, that is being rendered through the following jinja2
I have the following HTML Tags: <input id="bigPicture" name="bigPicture" type="file" value=""> <img src="test.png" id="test1">
I have the following HTML. <ul> <li> <a>asdas</a> </li> </ul> In my CSS stylesheet
I have a layout page with the following _app.cshtml <div id=top_right> @{ Html.Partial(_LogOnPartial); }

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.