2017-12-31 121 views
1

이렇게하면 "예기치 않은 스크립트 끝"(마지막 줄)이 표시됩니다.JS : 예기치 않은 스크립트 끝

무엇이 문제 일 수 있습니까?

(document).ready(function(){ 

    $(".btn btn-primary").click(function() { 
     chooseIngredient(1); 
     chooseIngredient(2); 
     chooseIngredient(3); 
     alert("veikia"); 
    }); 
} 

감사합니다!

+3

당신은 당신이 jQuery의'$'함수를 호출 document''에 전달하는 의미 가정, 닫는 괄호 –

+1

... 그리고 개방'$ '가 누락되었습니다. –

답변

1
$(document).ready(function(){ // USE $ 

    $(".btn btn-primary").click(function() { 
     chooseIngredient(1); 
     chooseIngredient(2); 
     chooseIngredient(3); 
     alert("veikia"); 
    }); 
}); // HERE you must have) opened by ready(
+1

jQuery이므로'$ (document) .ready'도 필요합니다. 그렇지 않으면'Uncaught TypeError : document.ready가 함수가 아닙니다'라는 메시지가 나타납니다. – thmsdnnr

+0

좋은 지적입니다. 감사. – GhitaB