• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 528
  • Last Modified:

jquery how do I exclude all divs that are not nested with a certain class name

I have a hidden div at the bottom of my page where I plan to put a div with text inputs and buttons.  I am going to be dynamically cloning this and adding it to my page to make a way for users to enter more results by clicking an add button which will add a new row of inputs.  This is working now.  I want to add event handlers to the buttons on the newly added rows so I was thinking that I can just nest my template in a class called Template.  Then when I add my event handlers, I could just search for anything that is not under a div with the class of Template.



This is
0
jackjohnson44
Asked:
jackjohnson44
2 Solutions
 
amit_gCommented:
Have you tried the live? This way any new controls with same criteria get attached to the same event handler.

http://docs.jquery.com/Events/live
0
 
HaloWebProjectsCommented:
why dont you use jquery "live" event handler/listener

http://docs.jquery.com/Events/live

basically what is does is allows you to register a click event listener on a selector for an object that does not exist in the DOM yet, but will exist later on...

for ex:

$('#id_of_new_element').live('click', function(){
   // code here ...
  return false;
});
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now