2014-07-24 4 views
-1

어쩌면 나는 이것을 볼 수 없다.jQuery .on() throws Uncaught TypeError : undefined is not function

mouseover가 정상적으로 작동합니다. mouseout에서 "Uncaught TypeError : undefined is not function"오류가 발생합니다.

$(document).ready(function(){ 
    $("tr").on("mouseover", function(){ highlightRow(); }); 
    $("tr").on("mouseout", "lowlightRow"); 
}); 

function highlightRow() { 
    console.log("highlightRow"); 
} 

function lowlightRow() { 
    console.log("lowlightRow"); 
} 

감사합니다.

+2

당신은 ("로 마우스", lowlightRow)에 그것은 $ ("TR")'의 문자열 "lowlightRow" –

+0

을 통과해야한다 ('이 아닌'$. "tr"). on ("mouseout", "lowlightRow");'. 'string'이 아닌'function'을 전달해야합니다. – melancia

답변

1
$("tr").on("mouseout", lowlightRow); // <-- passes function reference 

하지

$("tr").on("mouseout", "lowlightRow"); // <-- passes string 
5

당신은 함수를 전달해야합니다. 함수 이름을 따옴표로 묶으면 변수 대신 문자열 리터럴이됩니다. 그들을 제거하십시오.

$("tr").on("mouseout", lowlightRow); 
1
$("tr").on("mouseout", "lowlightRow"); 

$("tr").on("mouseout", lowlightRow); 
관련 문제