Javascript Myscript在我的本地主机中不工作,但如果在jsfiddle中,则为';很好
我不知道我的代码出了什么问题。如果我的脚本在jsfiddle中运行,那么就可以了。但是,如果在我的计算机(localhost)中,它不工作 以下是我的JSFIDLE: 这是我在电脑上运行的脚本Javascript Myscript在我的本地主机中不工作,但如果在jsfiddle中,则为';很好,javascript,jquery,html,css,localhost,Javascript,Jquery,Html,Css,Localhost,我不知道我的代码出了什么问题。如果我的脚本在jsfiddle中运行,那么就可以了。但是,如果在我的计算机(localhost)中,它不工作 以下是我的JSFIDLE: 这是我在电脑上运行的脚本 <html> <body> <input id="nominal" type="text" /> <script> $(function() { var money = 20000; $("#nominal").on("change key
<html>
<body>
<input id="nominal" type="text" />
<script>
$(function() {
var money = 20000;
$("#nominal").on("change keyup", function() {
var input = $(this);
// remove possible existing message
if( input.next().is("form") )
input.next().remove();
// show message
if( input.val() > money )
input.after("<form method=\"post\" action=\"\"><input type=\"submit\" name=\"yes\" value=\"Yes\"><input type=\"submit\" name=\"no\" value=\"No\"></form>");
});
});
</script>
</body>
</html>
$(函数(){
var货币=20000;
$(“#标称”)。在(“更改键控”,函数()上{
var输入=$(此);
//删除可能存在的消息
if(input.next().is(“form”))
input.next().remove();
//显示消息
if(input.val()>money)
输入。在(“”)之后;
});
});
要使用jQuery函数,您需要包括jQuery库:
将此项放在脚本标记上方:
<script src="https://code.jquery.com/jquery-3.1.0.slim.js" integrity="sha256-L6ppAjL6jgtRmfiuigeEE5AwNI2pH/X9IBbPyanJeZw=" crossorigin="anonymous"></script>
<script>
$(function() {
var money = 20000;
$("#nominal").on("change keyup", function() {
var input = $(this);
// remove possible existing message
if( input.next().is("form") )
input.next().remove();
// show message
if( input.val() > money )
input.after("<form method=\"post\" action=\"\"><input type=\"submit\" name=\"yes\" value=\"Yes\"><input type=\"submit\" name=\"no\" value=\"No\"></form>");
});
});
</script>
$(函数(){
var货币=20000;
$(“#标称”)。在(“更改键控”,函数()上{
var输入=$(此);
//删除可能存在的消息
if(input.next().is(“form”))
input.next().remove();
//显示消息
if(input.val()>money)
输入。在(“”)之后;
});
});
它将把jQuery从CDN加载到您的页面。您需要包括jQuery库才能使用jQuery函数: 将此项放在脚本标记上方:
<script src="https://code.jquery.com/jquery-3.1.0.slim.js" integrity="sha256-L6ppAjL6jgtRmfiuigeEE5AwNI2pH/X9IBbPyanJeZw=" crossorigin="anonymous"></script>
<script>
$(function() {
var money = 20000;
$("#nominal").on("change keyup", function() {
var input = $(this);
// remove possible existing message
if( input.next().is("form") )
input.next().remove();
// show message
if( input.val() > money )
input.after("<form method=\"post\" action=\"\"><input type=\"submit\" name=\"yes\" value=\"Yes\"><input type=\"submit\" name=\"no\" value=\"No\"></form>");
});
});
</script>
$(函数(){
var货币=20000;
$(“#标称”)。在(“更改键控”,函数()上{
var输入=$(此);
//删除可能存在的消息
if(input.next().is(“form”))
input.next().remove();
//显示消息
if(input.val()>money)
输入。在(“”)之后;
});
});
它会将jQuery从CDN加载到您的页面。您需要将jQuery包含到文件中。本地主机中是否包含jQuery?我必须包含哪些jQuery@scrappedcola@Eightleven使用最新版本:您需要在文件中包含jquery本地主机中是否包含jquery?我必须包含哪些jquery@scrappedcola@Eightleven使用最新版本: