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

  • Home
  • SEARCH
  • 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 8359743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:14:47+00:00 2026-06-09T11:14:47+00:00

Fiddle: http://jsfiddle.net/8TxmK/ I have two divs, one which has class=bb and another with no

  • 0

Fiddle: http://jsfiddle.net/8TxmK/

I have two divs, one which has class=”bb” and another with no classes. In my jquery, I apply the following functions:

$('div').on('click',(function(){

    $(this).addClass('bb');

}));

$('.bb').on('click',(function(){

    alert('bb class clicked')

}));

So I want to addClass ‘bb’ to the second div when clicked. This works fine. However, the second part ‘bb’ on click doesn’t work for the div which ‘bb’ class wasn’t loaded from the beginning.

Is there any workaround for this?

I have tried this: http://jsfiddle.net/M8Ja4/
But the function repeats itself once more each time.

  • 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-09T11:14:48+00:00Added an answer on June 9, 2026 at 11:14 am

    Yes.. delegate. Replace body with the closest parent that exists when the dom is loaded

    $('body').on('click','.bb',function(){
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
I have following fiddle: http://jsfiddle.net/BFSH4/ As you see there are two issues: The h1
I have this fiddle : http://jsfiddle.net/XjeCf/1/ that works like I want and this one
In this fiddle http://jsfiddle.net/SySRb/40/ , I created an array with two elements, #f-ONE and
I have this fiddle http://jsfiddle.net/jdsans/38GFS/ which I was trying to workout but I could
I have this fiddle: http://jsfiddle.net/yub2B/4/ HTML: <input type=text /> <input type=text /> <input type=text
I have this Fiddle: http://jsfiddle.net/GSA5R/2/ Whereby i use the border property to create the
See this fiddle: http://jsfiddle.net/uqJHf/ I have set the first column to show up with
This is best explained with a Fiddle: http://jsfiddle.net/hxsJx/ I want to add a class
Consider the following Fiddle: http://jsfiddle.net/wNrqu/ For the last 4 hours I have been trying

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.