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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:07:13+00:00 2026-05-26T22:07:13+00:00

I have the following HTML: <div id=Content> <div class=MyDiv>…</div> <div class=MyDiv>…</div> </div> The MyDiv

  • 0

I have the following HTML:

<div id="Content">
  <div class="MyDiv">...</div>
  <div class="MyDiv">...</div>
</div>

The MyDiv elements are removed and added several times as the result of an ajax call. I use the a function that uses the .html() function to replace the HTML.

When the page loads, I execute the following function:

function DynamicHandlers() {

     $('#Content .MyDiv').live({
        click: function () { .... },
        mouseleave: function () { ... }
    });

The problem is that the click and mouseleave handlers are executed as many time as I’ve changed the HTML. I initially had the handlers tied to the creation of the HTML and I’d bind the events each time the HTML was updated. I thought that by moving the handlers to the function that uses the .live(), I only had to run it once and then the handlers would be set for good. Which they are; the only problem is that they get executed multiple times.

What are the changes I need to make?

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-26T22:07:14+00:00Added an answer on May 26, 2026 at 10:07 pm

    Your handler will be invoked for each element in the DOM that matches the $(‘#Content .MyDiv’) selector. I assume that at the time the event is fired there are multiple elements on the page that match.

    • 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: <div id=mydiv> </div> I would like to load content
I have the following bit of HTML <div class=article>this is a div article content</div>
I have the following HTML: <div class=accordion> <h3>My title</h3> <div>My content</div> <h3>My title</h3> <div>My
I have the following HTML <div id=testID class=test1> <img id=testID2 class=test2 alt= src=some-image.gif />
I have the following html markup: <div class=wrap_select> <span class=select id=selectdateRange>Today, 25 March, Sun</span>
I have the following HTML: [...] <div class=row clearfix> <div class=col1>Data</div> <div class=col2>Data</div> <div
I have the following HTML: <div id=header> </div> <div id=content> <div id=test></div> <div style=height:1280px;></div>
I have the following HTML: <div class=wrapper> <div class=label> foor bar baz </div> <img
I have the following HTML code: <fieldset> <legend><span>Contact Details</span> <span class=edit1>Edit</span><span class=hide1>Hide</span></legend> <div> <!--content-->
I have the following HTML and CSS: <div id=topdevelopments class=colnm colw6 clearfix> <a href=homes-for-sale/development/beaufort-park-6/

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.