I added a span with a class, but .click does not trigger.
Adding a span class code
var TA = '<span class="TS" id="'+$('#TT').attr('value')+'" style=" color:#fff; margin-left:5px; font-family:arial; font-size:12px">* '+$('#TT').attr('value')+'</span>';
$('#QLT').append(TA);
This adds a span .TS to a div .TX. I want to trigger .TS using .click, the code
$('.TS').click(function() {
alert("ok");
});
But this does not trigger. What is wrong, Appreciate all assistance.
Thanks
Jean
You probably defined the click handler before you did
$('#QLT').append(TA). Thus the click handler didn’t know about the new element with class.TSwhen it was bound.You can manually re-bind it, or use jQuery’s cool live function, which will automatically bind when a new element with class
TSis inserted into the DOM: