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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:28:07+00:00 2026-05-14T05:28:07+00:00

in my html page, I have the following: <div id=rub> Select at least one

  • 0

in my html page, I have the following:

<div id="rub">
    Select at least one Rub
</div>

In the script code, I have

if ( some condition ... )
  $('rub').replace("Rubs selected:");

Which works fine, but when a second event is triggered, in the code I have

if ( some other condition ... )
  $('rub').replace("Selected at least one item:");

That gives the error

 $("rub") is null

It’s as if the rub reference was lost after the first replace. (Also tried with Element.replace with the same result)

Any clues ? Thanks in advance.

  • 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-14T05:28:07+00:00Added an answer on May 14, 2026 at 5:28 am

    You’re getting

    $("rub") is null
    

    because at that point you are trying to manipulate an element that doesn’t exist anymore because you replaced it with a text node.

    When you are calling

    $("rubs").replace("Rubs selected:");
    

    You are taking a DIV element with an ID of “rubs” and replacing it with a text node with no ID.

    You need to use:

    $("rubs").replace("<div id='rubs'>Rubs selected:</div>");
    

    or probably better:

    $("rubs").update("Rubs selected:");
    

    Remember, when using a JavaScript framework like Prototype, the docs are your friends. When you are having trouble with a function, the first thing you should do is carefully read the docs for that function. I’ve never used Prototype in my life, all I did was check the docs for the function you were using and the answer to your problem was right on the first line (to be fair though I can see how you might have missed it if you did read the docs).

    Hope this helps.

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

Sidebar

Related Questions

The HTML page is supposed to have the following code: <div class=user-image style=background-image:url(/images/user_image.jpg)> How
I have the following code in an html page: <script type=text/javascript> function industry(industryid) {
I have following HTML code: <div id=wrapper> <div class=page id=first> Test<br/> Test<br/> Test<br/> Test<br/>
I have the following piece of HTML page: <div id=main> <div id=description> Some text
I have the following elements in a HTML page: <body> <div style=height:100%; width:100%> <div
In the following HTML page, I have a div, which contains two spans (
I have the following HTML on a Jquery Mobile Page: <div data-role=controlgroup data-type=horizontal class=panelSwitcher>
I have the following jQueryMobile page anatomy at index.html: <div data-role=page> <div data-role=header>...</div> <div
i have the following code to try and load a local html page in
i have following code for inserting another page into div An XHTML 1.0 Strict

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.