View Single Post
Old 03-22-2009, 04:18 AM   PM User | #1
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Registering an element into the DOM

I'm using the html() modification function to create an <img> tag with a certain class name. The image appears fine, but I have a jQuery event $(".classname").click() that will not register on this new image I've created. It works on all images with that class name otherwise; just the images that I dynamically create using html() don't seem to get properly added to the DOM in a place where they are then recognized by other jQuery actions.

Is there a way to get this to work?

Event code on image click is:

Code:
$(".editbtn").click(function() {
    alert("got clicked");
});
Code that creates the image is:

Code:
$("#tnbrdisp").html(textString + '<img id="edittrknbr" class="editbtn" src="images/edit.png" alt="edit number" title="edit number" />');
__________________
Fumigator is offline   Reply With Quote