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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:53:10+00:00 2026-05-16T23:53:10+00:00

what happens if the element I am binding jQuery code to is not found

  • 0

what happens if the element I am binding jQuery code to is not found on the page?
Does the previous binded code breaks?

Let me explain it with a sample. I have the following code inside my page:

<script type="text/javascript">
$(document).ready(function() {
    $('.deleteMemo').live('click', function() {
        $.ajax({
            [ajax call omitted for brevity]
        });
    });

    $('.markAsViewed').live('click', function() {
        $.ajax({
            [ajax call omitted for brevity]
        });
    });
});
</script>

Now, depending on the page status in the page there could be:

  • Only elements with “deleteMemo” class
  • Only elements with “markAsViewed” class
  • Both

I am experimentig that, in the first case (only “deleteMemo” elements), the jQuery code does’nt get called at all. I still have not did a try with the other cases but I have triple checked the code and even looked at it with fiddler.

Any suggestion?

  • 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-16T23:53:11+00:00Added an answer on May 16, 2026 at 11:53 pm

    It does not matter if the elements are on the page when calling .live() because .live() does not bind the handler to the actual elements.

    This is the purpose of using .live(). It allows elements that are dynamically added to the page to fire a handler that was added before they existed.

    If any ancestors of a .deleteMemo (for example) stops event bubbling from taking place, then live() will not work for that element.

    So if you have any click handlers on any of the ancestors that either have:

    event.stopPropagation();
    

    or:

    return false;
    

    …in them, the live() handler will not fire.

    Of course if the selector doesn’t match (check capitalization for example) then the handler won’t fire.

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

Sidebar

Related Questions

What happens in the following code? Does the synchronization work? This is an interview
in jquery when I use element that doesn't exist what happens? Consider: $('<tmp/>').html(some_html_string).text() where
This function only works once, when I click an anchor element again, nothign happens.
What happens when an application pool is recycled in IIS 7? Does IIS abruptly
I have kind of a theory question on what happens when you have jQuery
I want to add selected options from select element to binding table. The view
What happens when an element has multiple class attributes? <div id=test class=one two three
Check the test page here http://rickchristie.com/testfocus.html Correct me if I'm wrong: onfocus happens when
This happens to be the top padding plus the bottom padding on the element
Here's a fiddle illustrating the problem. I am adding a jQuery one binding on

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.