The "a.delete" click handler only attaches to _current_ elements on the page. If you want to bind to future elements (that you build dynamically) you can use the .live method:
$("a.delete").live( "click", function(){ alert( "test" ); } ); (Also, another solution is to take advantage of event delegation by only attaching a click handler to the parent object, then figuring out which child was clicked. On Nov 11, 5:22 am, "s.soch" <soraya_s...@yahoo.com> wrote: > Hi, > > I'm attempting to build a list of items that are to be clickable to > delete. > > - I am able to visually build the list and it is added to a div I > want. > > My a.delete click event is never triggered when I click on a json > built hyperlink. > If I manually add the html like <a class='delete'>test</a> then the > event is triggered (which tells me it shouldn't be a javascript > error...). > > What am I missing? > Tia, S. > > My jquery functions look like: > > $().ready(function() { > $('#members').click(function(){ > $.getJSON("check_group_membership.php", {members:$("#members").val > (), groups:$("#groups").val() } , function(json){ > var output = ""; > for (var i = 0; i < json.length; i++) { > //alert( json[i].name ); > output+= "<a class='delete'>" + json[i].name + > "</a><br>"; > } > $("#assignedGroups").append( output ); > }); > }); > > $("a.delete").click(function() { > alert("test"); > > }); > >