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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:28:59+00:00 2026-05-19T03:28:59+00:00

in short, i have a page where the content is being loaded with jquery

  • 0

in short, i have a page where the content is being loaded with jquery load(). the problem is when i am trying to select.

$('a.selected_class').click(function(e){
 alert('alert');
 e.preventDefault();
});

(inside document ready) works on the first page, but on any subsequent pages (that are loaded using $(this).load(url); into a div), the selector stops working.

any tips?

  • 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-19T03:29:00+00:00Added an answer on May 19, 2026 at 3:29 am

    It isn’t that it stops working. It is that it only binds click handlers to those elements that exist when it runs (on page load).

    You can place a .delegate() handler on the <div> that the dynamic ones are loaded into.

    $('#mydiv').delegate('a.selected_class','click',function(e){
       alert('alert');
       e.preventDefault();
    });
    

    The handler is placed on the #mydiv element, and when the click event bubbles up to it, it tests to see if the event took place on an element that matches a.selected_class.

    The .live() method does the same thing, but it does it for the entire document, so it normally isn’t an advisable method to use.

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

Sidebar

Related Questions

I have part of a page being dynamically refreshed via the jQuery load() method,
Say that I have an article with multiple pages. Each page has a short
I have some sort of a jquery chat at one specific PHP page. Of
I have two div columns sidebar(left) and page-content(right). I toggle removing and adding 'sidebar'
I have a page which displays dynamic flash content from issuu.com. I need to
I am puzzled, I have a call with jQuery using .load to fill a
I already have a function on my page that produces url from curl. I
I have a page in my application that refreshes some content (a list of
I have a page which uses a fair bit of ajax to load its
SHORT DESCRIPTION: For example we have two pages. The second page contain block which

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.