我的代碼存在問題。我用一個按鈕來隱藏和顯示一個菜單,但它不起作用。我不明白這個問題。切換按鈕沒有工作?(未捕獲的SyntaxError:意外的標識符)
Uncaught SyntaxError: Unexpected identifier :: par. 3
$(function() {
$(".but").click({
if $("#div").hasClass("class"){ //problem is here
$("#div").removeClass("class").addClass("anotherclass");
} else{
$("#div").removeClass("anotherclass"").addClass("class");
}
});
});'
是那個撇號在最後一個錯字嗎? – richbai90
你缺少'function()'。請查看文檔中的示例http://api.jquery.com/click/,它應該很清楚。 –
我想,是的。 – YigitKoc