我是一名新的 javascript 程序员,我遇到了这个问题:
Uncaught ReferenceError: saluta is not defined
at HTMLButtonElement.onclick ((index):33)
在此代码上:
<button onclick="saluta()" id = "btn_sa">LOGIN</button>
这是函数:
function saluta(){
var username = document.getElementById("Name").value;
var password = document.getElementById("Password").value;
var blocco = $("<div></br>Ciao </div>");
if(password === "errata"){
$(blocco).append(x);
blocco.appendTo(document.body);
document.getElementById("btn_sa").disabled = true;
}else{
$(blocco).css({
"color" : "red"
"font-size" : "10px"
});
$(blocco).append("Password Errata");
blocco.appendTo(document.body);
}
}
如何解决?我在论坛里发现很多人和我有同样的问题,但我无法解决! p.s 抱歉,如果我的英语不是很好
最佳答案
您的代码包含错误
"color" : "red"
行尾缺少 ,
关于javascript - jQuery onclick 错误函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41653215/