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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:49:43+00:00 2026-05-25T01:49:43+00:00

I got this html code from a book that i’m using to learn jquery

  • 0

I got this html code from a book that i’m using to learn jquery i modified it a little bit

<body>
<h4><i>More</i> Mitch Hedberg Quotes</h4>
<div>
  <input type='submit' id='tmpQuote1' value='View Quote' />
</div>
<div>
  <input type='submit' id='tmpQuote2' value='View Quote' />
</div>
<div>
<p id="paragraph"> some text that will disappear</p>
</div>

$(document).ready(
function() {
$('p').mouseover(
function(){
$(this).replaceWith("<p> the text changed to this text </p>");
}
);

$('input#tmpQuote1').click(
  function($e) {
    $e.preventDefault();

    $(this).replaceWith(
      "<p>\n" +
      "  I would imagine that if you could understand \n" + 
      "  Morse code, a tap dancer would drive you crazy.\n" +
      "</p>\n"
    );
  }
);

$('input#tmpQuote2').click(
  function($e) {
    $e.preventDefault();

    $(this).replaceWith(
      "<p>\n" +
      "  I'd like to get four people who do cart wheels \n" +
      "  very good, and make a cart.\n" +
      "</p>\n"
    );
  }
);

Basically when I hover over the the last paragraph it changes text .
when I click on those two buttons they do change to paragraphs + text.
so far so good. But the problem I’m having is understanding why when I hover over the first & second (newly spawned) paragraphs , the mouseover doesn’t work. Is there a delay in Jquery parser. Or maybe I do not know exactly how $this works.

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-05-25T01:49:44+00:00Added an answer on May 25, 2026 at 1:49 am

    change .click into .live('click',function(){...}); and you’ll be good. The reason is stated above: Event handlers are only added to content which is already there. If you want to add it to every content you add dynamically, you have to use .live.

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

Sidebar

Related Questions

This is my code: from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from
I got this example demonstrating AJAX from Stoyan Stefanovs Object Oriented JavaScript at page
I've got to add a new row with it's content populated from an ajax
So I got this form: <form action=welcome.php method=post> <input type=hidden name=secret value=<?php echo getMyValue()
I've got some HTML which has some dynamically generated forms which are submitted via
This question may be a bit specific for stackoverflow, but here it is. I
I'm very new to PHP so far and have been trying to learn it.
If i go to http://tourscript.com/hrsportal_last/hotel_details.asp?id=1 and select check in 21 to 24 April i
I'm new to Ruby & Rails, and am currently working on the Rails Tutorial
Possible Duplicate: Why is the `gets' function is dangerous? Why should not be used?

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.