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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:00:55+00:00 2026-05-27T17:00:55+00:00

I want to attach a event to dynamically created element class.So i used live

  • 0

I want to attach a event to dynamically created element class.So i used live function but it was not triggered. So checked live function reference ,there i red below notes

As of jQuery 1.7, the .live() method is deprecated. Use .on() to
attach event handlers. Users of older versions of jQuery should use
.delegate() in preference to .live().

so decide to use on function,But it still not working.The text field is already attached with jquery ui datpicker.On another element select i disabled that field.

jQuery("#from").attr('disabled','disabled')
.removeClass('date_picker_bg')
.removeClass('hasDatepicker')
.addClass('date_picker_disabled');

after disabled if i click i want to show alert or tooltip.so i tried this,but not working

jQuery(".date_picker_disabled").on("click", function(event){
          alert('hi');
  });

What may be the problem

I am using jquery 1.7.1 ( jquery-1.7.1.min.js)

  • 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-27T17:00:55+00:00Added an answer on May 27, 2026 at 5:00 pm

    The problem is that jQuery(".date_picker_disabled") finds elements with that class and binds to them. If elements don’t have the class at the time the binding is made, the events will not be handled.

    The on function allows you to get round this by handling them on another element when the event “bubbles up to” a parent element. In this instance, we could say the body element – there may be a more specific common parent you could choose.

    jQuery(document.body).on('click', '.date_picker_disabled', function(event) {
        alert('hi');
    });
    

    The event handler is now bound to the document.body element. All clicks that happen anywhere in the body are tested to see if they originated from an element matching the selector. If so, the handler is fired.

    This is explained on the documentation for the on function. It is the same behaviour as was present in previous versions of jQuery with live and delegate functions.


    Having taken another look at your code, you have disabled="disabled" set on your input element. click events are not fired on disabled elements.

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

Sidebar

Related Questions

I want to attach onclick event to month_head class and get value of inner
I want to attach a 'click' event handler to the first child of an
Want the function to sort the table by HP but if duplicate HPs then
I want to attach a click event at the document level with $(document).click(); And
this works great in FF but not in IE, Chrome or Safari. $('#countryDropDown option').click(function()
The Objective I want to dynamically assign event handlers to some divs on pages
I am creating a grid panel and want to attach an event with each
I have an event on one of my classes that I want to attach
Can I attach any event handlers to HTML hidden input fields? Basically I want
I have a clickable marker that I want to attach either a 'class' or

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.