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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:59:53+00:00 2026-05-27T18:59:53+00:00

I have a portion of code that is dynamically loaded via an AJAX call

  • 0

I have a portion of code that is dynamically loaded via an AJAX call by appending the result to a parent element, similar to this:

<div class="parent">
     <!-- Inner content loaded dynamically -->
     <div class="child">
     </div>
     <div class="child">
     </div>
     <!-- ... -->
</div>

Now, in order to hook up a mouseover event, I would do something like this:

$(".parent").on("mouseenter", ".child", function(){
 //Do fun stuff here
}

$(".parent").on("mouseleave", ".child", function(){
 //Undo fun stuff here
}

This works well enough for standard functions, but I want to attach this to a third-party plugin (in my case, HoverIntent, but really any plugin) –

The syntax for attaching the HoverIntent plugin is as so:

$(".child").hoverIntent( makeTall, makeShort )

… but I want this to work for my dynamic content that was not available at the time the document initially loaded, and something like $(".parent").on("hoverIntent", ".child", function(){}); doesn’t seem to be the right way to do this.

What is the correct approach to applying a plugin to elements loaded after the initial $(document).ready()?

  • 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-27T18:59:54+00:00Added an answer on May 27, 2026 at 6:59 pm

    jquery .on works by monitoring events on a parent object and then calling the handler if the event originated from a matched child selector. In your case, however, the event you want to monitor is that the element changed

    Browsers fire the onchange event for input elements only (because they can be changed by a user).

    If any other element changes, it must be because of javascript, hence you can call functions after created new content.

    $(".child", parentElementContext).hoverIntent( makeTall, makeShort )
    

    There are 2 practical solutions

    1) What i typically do is create an init method that takes a context (such as the document).

    MyPage.init = function(context) {
        $('.selector', context).hoverIntent();
        $('.other', context).dialog(); // any other plugins
    };
    

    Then I manually call init when I update the DOM (because i dont always need to call init when I update the dom)

    $.ajax({
      url: url,
      data: data,
      success: function(data){ 
         var context = $('.parent'); 
         context.html(data);
         MyPage.init(context); //calls hoverIntent and other plugins
      }
    });
    

    2) If you really need to monitor everything, you can use this plugin
    http://james.padolsey.com/javascript/monitoring-dom-properties/

    and then $('.parent').on('valuechange', function() { /* init plugins*/}

    • 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 code: (that gets loaded via ajax into a div)
Let's say we have a code portion like this: IProduct product = ProductCreator.CreateProduct(); //Factory
In a portion of legacy code that I have been asked to work with,
I have some portion of code that needs to be executed in each thread
I have this portion of code: var hasAttribute = TypeDescriptor.GetAttributes(property.DeclaringType).OfType<CrmTypeAttribute>() .Any((attr) => ((CrmTypeAttribute)attr).Name ==
I have a portion of a bash script that is getting a filename without
I have an html page i want to print a portion of this html
The problem: we have one application that has a portion which is used by
I am building a site that will (obvisouly) have a front end public portion
I have an image loader that I am attempting to resize dynamically. I would

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.