gpt4 book ai didi

javascript - jQuery onkeyup 事件 : scan not defined

转载 作者:行者123 更新时间:2023-12-03 09:45:48 25 4
gpt4 key购买 nike

显示:

Uncatched Reference error: scan not defined.

这是代码:

<html>
<head>
<script type="text/javascript" src="../js/jquery.js"></script> <script type="text/javascript">

$(document).ready(function() {
function scan() {
$("#result").text("<font style='color: green;'>Cote</font>"); console.log("Function ran");
}

});

</script>
</head>
<body>
<font style="font-size: 84px;">Scan card, please</font>
<p id="result">cotes</p>
<input style="font-size: 36px;" id="input" maxlength=16 autofocus onkeyup="scan();">
</body>
</html>

最佳答案

scan 方法定义应该在其他函数的范围之外。看看你应该如何修改你的代码:

function scan() {
$("#result").text("<font style='color: green;'>Cote</font>");
console.log("Function ran");
}

$(document).ready(function() {
// remove if not necessary
});

关于javascript - jQuery onkeyup 事件 : scan not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31037552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com