views:

14

answers:

1

hellooo, I have this code

BOX

and After:

$(".boxAlert").click(function(){ $(this).remove(); //$(this).fadeOut(500); });

It's OKAY, when I click on the SPAN with class boxAlert, it removes it.

But I can not remove the SPAN's I created this way..

$('#myDiv').append('Invalid Mail');

The SPAN I create this way appears in the page and has the class boxAlert, applied, but I can not remove it or fadeOut or anything..

Any ideas?

+1  A: 

Use the live() method:

$(".boxAlert").live('click', function(){
  $(this).remove();
});

The live() methods works for elements present now or those coming in future.

Sarfraz
mmm.. will try inmediately... Tx..
Pedro
Work like a charm... I think indeed that this objects weren't not in the page when code was ready... But didn't know nothing about "live"... I've learn something new today.. And still a lot to learn.Thanks for your help...Pedro
Pedro