What to research for new elements with event listeners?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

What to research for new elements with event listeners?

Post by JAB Creations »

What should I research online to figure out how to get event listeners to recognize when new elements created by JavaScript (not via AJAX but just by a function) exist? The event listeners are loaded on my site onload, a user takes an action 40 seconds after the page loads that creates a new element via createElement, they click on the element however the event listeners don't see the newly created elements. Suggestions please?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: What to research for new elements with event listeners?

Post by pickle »

Put the code that adds the event listeners in a function x(). Call that function when a new element is created - not by listening, but by calling the x() when the code to create the new element is executed.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply