开发者

.remove does not work out - jQuery

开发者 https://www.devze.com 2023-02-06 07:10 出处:网络
I am 开发者_如何学Gotrying to remove an id, and .live is necessary, the code is below $(\'.TS\').live(\'click\',function() {

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

精彩评论

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