Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12444 closed bug (invalid)

jquery click event not firing on dynamically created div

Reported by: mtotoum@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

Description

for a week I tried every possible way to make this work on fireFox, Chrome or Opera and no use it works fine on IE

a sample of what I am doing is here

for (i=0;i<=3;i++){

myAlbumHTML +='<div style="width:150px;display:inline;" >'; myAlbumHTML +='<div style="vertical-align:text-top; display:inline-block; text-align: center; border: solid 2px #000080;" ' + 'ID="' + i + '" class="Albums" onclick="DoClick(this)" >'; myAlbumHTML +='<table><tr><td>'; myAlbumHTML +='<img src="Image/Src"'; myAlbumHTML +='" alt="" ></img>'; myAlbumHTML +='</td></tr><tr><td>'; myAlbumHTML +='Title</td></tr><tr><td>2nd Title' ; myAlbumHTML +='</td></tr></table></div></div>';

};

$("#cont").html(myAlbumHTML);

function DoClick(obj){alert($(obj).attr("ID"));}

I also tried $(".albums").on("click",DoClick);

its working just like I want on IE . . . but not on chrome or FF

Change History (1)

comment:1 Changed 7 years ago by timmywil

Resolution: invalid
Status: newclosed

Please ask for help on the forums or on the #jquery irc channel.

Note: See TracTickets for help on using tickets.