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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:39:47+00:00 2026-06-06T21:39:47+00:00

Using jQuery 1.7 I’m having trouble binding a Click event to some dynamically loaded

  • 0

Using jQuery 1.7

I’m having trouble binding a Click event to some dynamically loaded content.

I’ve looked around, tried .live, .delegate and .on, and I just can’t get it to work.

This is my code:

$(".fileexplorer_folderdlg").delegate(".delete", "click", function () {
        console.log("Hello world!");
    });

The thing is, .fileexplorer_folderdlg is dynamically loaded. If I use .fileexplorer (not dynamically loaded), it works, but I have more elements with the .delete class that I do not wish to bind to (and neither element classes can be renamed or changed for various reasons).

I also tried using .fileexplorer_folderdlg .delete as the .delegate selector, didnt work either!

Of course I could just add another unique class to the elements I wish to bind to, but this really should work, right?

  • 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-06T21:39:49+00:00Added an answer on June 6, 2026 at 9:39 pm

    I believe this would work:

    $(document).on('click', '.delete', function() {
        if ($(this).closest('.fileexplorer_folderdlg').length) {
             console.log('hello, world!');
        }
    });
    

    or even just:

    $(document).on('click', '.fileexplorer_folderdlg .delete', function() {
         console.log('hello, world!');
    });
    

    As you’ve found, you can’t bind on .fileexplorer_folderdlg because it’s dynamic. You therefore need to bind on some static element that will contain that element at some point in the future.

    Instead, this binds on the document (but will unfortunately fire for every single click on the document thereafter).

    EDIT by Jeff

    Although the code above did not work, modifying it a bit did the job, although not the most desirable solution.

    $(document).on('click', '.delete', function () {
            if($(this).closest(".fileexplorer") != null)
              console.log("Thanks for your help!");
        });
    

    It works, but this event is fired for all other .delete classes, of which there are many. What I do not understand though, is why using .fileexplorer_folderdlg .delete did not work!

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

Sidebar

Related Questions

Using jQuery, how do you bind a click event to a table cell (below,
Using jquery, I currently append html to a div on a click event. The
Using jQuery, I make these changes in the DOM: $(document).ready(function() { $('.editable').click(function() { var
Using jQuery 1.7.1, I'm trying to create an event handler for the change event
(using jquery) I have the following function $(function() { $('tr.parent') .css(cursor,pointer) .attr(title,Click to expand/collapse)
Using jQuery 1.5.1 Tried this block of code in: head section as well as
Using jQuery, I would like to capture a keyboard event that is: before the
Using jQuery , how can I dynamically set the size attribute of a select
Using jQuery timepickr: http://archive.plugins.jquery.com/project/jquery-timepickr Having included these files: jquery-1.7.1.min.js jquery-ui-1.8.21.custom.min.js ui.timepickr.js And getting this
Using jQuery I want to be able to click an element which will also

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.