-2

I am working on a notifications system. Please refer the fiddle here.

I tried to close the element using

this.remove();

It didnt work, no error either. I also tried:

this.parent.remove();

This gave an error:

Uncaught TypeError: Cannot call method 'remove' of undefined

How do I get the close button working properly?

Rahul Desai
  • 15,242
  • 19
  • 83
  • 138

1 Answers1

3

this refers to the dom element reference which does not have remove() method, you need the jQuery wrapper for the dom element.

Also you need to remove the parent div element

    $closeButton.click(function(){
        $(this).parent().remove();
    });

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531