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

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08
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
Question by:jackjohnson44
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 58

Accepted Solution

amit_g earned 1000 total points
ID: 26289772
Have you tried the live? This way any new controls with same criteria get attached to the same event handler.


Assisted Solution

HaloWebProjects earned 1000 total points
ID: 26289779
why dont you use jquery "live" event handler/listener


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;

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question