javascript - jQuery onclick 错误函数

标签 javascript jquery html

我是一名新的 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/

相关文章:

javascript - 需要开源 JavaScript onclick 工具提示解决方案

javascript - Ionic - 将毫秒(长)日期解析为 dd/mm/yyyy

javascript - React 组件的内联样式不起作用

javascript - 如何截取网页屏幕截图?

javascript - 删除 JQuery/Javascript 键盘 Hook (例如 Portfolio Slide Gallery)

javascript - jquery .val() 下拉菜单上的奇怪行为

javascript - bootstrap-datepicker 格式化日期输出

javascript - 汉堡导航栏激活问题?

php - 使用 PHP 和 CURL 创建新的 etherpad

html - 单击下拉导航栏时文本移动