开发者

.remove does not work out - jQuery

I am 开发者_如何学Gotrying 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


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

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


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜