Uncaught TypeError: Cannot call method 'toLowerCase' of undefined

后端 未结 4 2008
挽巷
挽巷 2021-02-06 23:49

I ran into a very vague error while doing some simple jQuery DOM manipulation.

The line that triggered the error is the following:

$(this).closest(\'tr\')

4条回答
  •  一生所求
    2021-02-07 00:37

    // assign this to a variable
    
    var val = this;
    
    // Use
    
    $(val).closest('tr').remove(); // It worked for me
    

    Instead of :

    $(this).closest('tr').remove();
    

提交回复
热议问题