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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:31:33+00:00 2026-05-11T14:31:33+00:00

HTML <div id=header>top of page</div> <div class=message>hello, how are you</div> <div class=message>I am fine</div>

  • 0

HTML

<div id='header'>top of page</div> <div class='message'>hello, how are you</div> <div class='message'>I am fine</div> 

jquery

$(document).ready(function () {     $('#header').append('<div class='message'>appended DIV</div>');     $('div.message').hover(         function () {             alert('hi');         },         function () {             alert('bye');         }     ); }); 

Why do the existing DIVs in the HTML trigger the mouse even and hence alert, but the appended DIV will not and is ‘dead.’ How can the appended DIV react like the existing ones?

edit: in summary this was the solution:

$('<span />').addClass('message').text('(mouse 1)').appendTo('#header'); $('<span />').addClass('message').text('(mouse 2)').appendTo('#header');  $('.message').hover(     function () {         $('#header').prepend('in');     },     function () {         $('#header').prepend('out');     } ); 

Note, if the SPANs are placed below the hover function, it won’t work.

  • 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. 2026-05-11T14:31:33+00:00Added an answer on May 11, 2026 at 2:31 pm

    Here is the resulting generated XHTML from your current code:

    <div id='header2'>put mouse here<div class='message'></div></div> 

    As you can see, the part you expect to hover over has no text.

    Try:

    $('<div />').addClass('message').text('appended DIV').appendTo('#header'); 

    You will now see the text inside a new div with the message class attached.

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

Sidebar

Related Questions

given the html: <div class=ships> <div class=ship header> </div> <div class=ship> <div class=image> <img
I have the following HTML. <body> <div class=header></div> <div class=navdiv></div> <div class=mainarea> <p></p> <table>
assume I have a such html order <div id=header>>Header(logo, navigation menus etc)will be here,
here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
I am processing a form at the top of my page before the html
Trying to place a header bar at top of a full page Google Map
hi here is my live page http://mehrdadkhoshbakht.com/test/index.html there is a jquery sliding animation on
hi I've created a fixed navigation bar/header at the top of a page with
I am trying to generate an html div in asp.net. Since a div is
What is the best way to set the transparency of a HTML DIV element

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.