내 js 파일에서이 함수를 호출하면 오류가 발생합니다.함수가 오류를 호출했지만 그 이유를 모르겠습니다. setTimeout()
function currentGrassColor(grassArea, color){
var grassField = $('.'+grassArea+'').find('img');
setTimeout(function(){grassField.attr('src', 'img/grass'+color+'.png')},1000);
}
function currentGrassColor(currentProgram_grassBg, Green);
그리고 이것은 내가 라인 4919 COL 93 예기치 않은 토큰 punc의에
오류 얻을 오류가«,», 예상 punc의«{»/ 응용 프로그램/MAMP는/htdocs에/기업/JS의 을
function currentGrassColor(grassArea, color) { var grassField = $('.' + grassArea + '').find('img'); setTimeout(function() { grassField.attr('src', 'img/grass' + color + '.png'); // was missing ; }, 1000); } currentGrassColor(currentProgram_grassBg, Green); // don't need function here you are calling it, not defining it
프로 팁 :
이 보이는 따옴표의 색상을 넣어해야 세미콜론 누락'에서는 setTimeout (함수() {grassField.attr (함수() {grassField.attr ('src', 'img/grass'+ color + ') .png ('src ','img/grass '+ color +'. ');}, 1000);' – VIDesignz
익명 함수의 끝에 세미콜론이 누락되었습니다. 그리고 함수를 호출하려고 할 때'function'이 필요 없습니다. –