2015-04-19 54 views
1

我:addClass造成不確定是不是一個函數

mouseOver: function() { 
    var catId = this.category_id; 
    $('#expenditureSummaryGrid .k-grid-content tr').each(function() { 
     if($('td span', this).data('id') == catId) { 
      this.addClass('grid-hover'); 
     } 
    }) 
}, 

但它給我:

Uncaught TypeError: undefined is not a function 

,因爲這是沒有做太大的意義「這」預期的DOM元素我我也嘗試添加一個類。

什麼問題?

回答

1

由於.addClass()是一個jQuery的功能,您可能需要更改

this.addClass('grid-hover'); 

$(this).addClass('grid-hover'); 
+0

哇,小學生錯誤大時間,謝謝! – imperium2335

0

的錯誤「這」是裏面的條件每個循環。你可以嘗試

 mouseOver: function() { 
          var catId = this.category_id; 
          $('#expenditureSummaryGrid .k-grid-content tr').each(function(){ 
           if(this.find('td span').data('id') == catId) { 
            this.addClass('grid-hover'); 
           } 
          }) 
         }, 
相關問題