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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:23:27+00:00 2026-06-02T00:23:27+00:00

I am trying to use jquery on method on 1.7.2 but I am having

  • 0

I am trying to use jquery on method on 1.7.2 but I am having trouble.

I am using this

$(function(){
$("a").on("click",'.displayBig', function(e) {
    e.preventDefault();
    alert('foo');
})});
<a href="images/large_4.jpg" class="displayBig" data="gallery0"><div id="magnify">dsfsfdsfs</div></a>​

​
It seems that my selector is not working.

I have created a jsfiddle here.

http://jsfiddle.net/BQDvM/

Thanks Guys.

  • 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-06-02T00:23:29+00:00Added an answer on June 2, 2026 at 12:23 am

    If you want to use the dynamic version of .on(), then you need to use this form:

    $(staticParentSelector).on('click', '.displayBig', fn);
    

    The staticParentSelector must be a selector that points to a parent of your dynamic objects and is present at the time you run the above jQuery to install the event handlers and it must be an object that is not destroyed and recreated after the event handlers are installed. The objects that match the second selector (I’ll call the dynamic selector) do not need to exist initially and can be created any time in the future.

    In the worst case, it could be this:

    $(document).on('click', '.displayBig', fn);
    

    Since the document object satisfies all the criteria for a static parent. But, your events will perform better if you pick a static parent that is much closer to your actual dynamic objects and if you do not use the document object for all dynamic events.

    So, if you had HTML like this:

    <div id="container">
        <a href="images/large_4.jpg" class="displayBig" data="gallery0">
            <div id="magnify">dsfsfdsfs</div>
        </a>
    </div>
    

    Then, you would use a dynamic version of .on() like this:

    $("#container").on('click', '.displayBig', fn);
    

    The way the dynamic version of .on() works is that it binds a single event handler to the static object. Then, when someone clicks on one of your dynamic objects, there are no direct event handlers on the object for the click so the click bubbles up through the ancestor objects. When the event gets to your staticParent object that has the event handler, it sees that there is a dynamic event handler installed and it compares the object that originated the event to the dynamic selector. If they match, it fires the event handler. If they don’t match, no event is fired.

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

Sidebar

Related Questions

I am trying to use the jquery autocomplete plugin but am having trouble getting
I am trying to use the jQuery POST function but it is handling the
Im trying to use this jQuery script and this is confusing me: function CallService()
I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
I am trying to use JQuery in my ASP.Net 2.0 website in this scenario:
I am trying to use the JQuery on() method. Basically I am trying to
I am trying to use the JQuery cookie plugin in my project but I'm
I'm trying to use the jQuery UI to style my HTML select menu but
I'm new to jquery, but I'm trying to use it to create a multi-step
Trying to figure out how to use the Jquery .on() method with a specific

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.