Javascript 我一直收到一个错误未捕获引用错误:nothingButton未定义

Javascript 我一直收到一个错误未捕获引用错误:nothingButton未定义,javascript,html,Javascript,Html,所以我一直得到这个错误,什么按钮都没有定义。但我定义了它。有人知道发生了什么吗 JavaScript: function nothingButton() { $("#button-nothing").on('click', function() { $(this).prop('disabled', true); const p = document.createElement('p'); p.innerText

所以我一直得到这个错误,什么按钮都没有定义。但我定义了它。有人知道发生了什么吗

JavaScript:

    function nothingButton() {
    $("#button-nothing").on('click', function() {
        $(this).prop('disabled', true);
        const p = document.createElement('p');
        p.innerText = "Well, except for this";
        document.querySelector('#button').appendChild(p);
    })
}
HTML:


这个按钮不起作用

我的html文件中也有javascript文件源代码。

好吧,上面的代码实际上很好

可能是代码中的其他内容,或者只是一些排版错误

除此之外,您可能会收到2条“嗯,除了这个”消息,因为每次单击按钮,它都会附加另一个单击侦听器

以下是我为您重新创建的内容:


这个按钮不起作用
函数nothingButton(){
$(“#按钮无”)。在('单击',函数(){
$(this.prop('disabled',true);
const p=document.createElement('p');
p、 innerText=“嗯,除了这个”;
document.querySelector(“#按钮”).appendChild(p);
});
}
//连接事件侦听器一次。
无按钮();
初始状态:

按钮单击状态:

<div id="button">
<button id="button-nothing" onclick='nothingButton()'>This button does nothing</button>
</div>