X10nD
X10nD

Reputation: 22050

.remove does not work out - jQuery

I am trying to remove an id, and .live is necessary, the code is below

$('.TS').live('click',function() {
    ("#"+$(this).attr('id')).remove();
});

The error got from chrome

Uncaught TypeError: Object #first has no method 'remove'

I tried removeId, but the above error message.

Appreciate all help

Thanks Jean

Upvotes: 0

Views: 947

Answers (2)

Alpesh
Alpesh

Reputation: 5405

Try this, although it is an indirect way but it works -

$('.TS').live('click',function() {
    $(this).attr('id','');
});

Upvotes: 0

lonesomeday
lonesomeday

Reputation: 238065

You are calling the remove method on a string. You should make a jQuery selection using this:

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

Upvotes: 3

Related Questions