gpt4 book ai didi

javascript - jquery 文件未与 html 文件链接

转载 作者:行者123 更新时间:2023-11-28 00:25:04 24 4
gpt4 key购买 nike

jquery 文件似乎没有与我的 html 代码链接。 jquery 文件应该验证输入并根据验证添加相应的字形图标。我尝试过搜索错误、关闭标签,但找不到任何问题。有人可以检查一下并指出我正确的方向吗?提前致谢。

//validate.js
function validateText(id) {
if ($("#" + id).val() == null || $("#" + id).val() == "") {
var div = $("#" + id).closest("div");
div.removeClass("has-success");
$("#glypcn" + id).remove();
div.addClass("has-error has-feedback");
div.append('<span id="glypcn' + id + '" class="glyphicon glyphicon-ok form-control-feedback"></span>');
return false;
} else {
var div = $("#" + id).closest("div");
div.removeClass("has-error");
div.addClass("has-success has-feedback");
$("#glypcn" + id).remove();
div.append('<span id="glypcn' + id + '" class="glyphicon glyphicon-ok form-control-feedback"></span>');
return true;
}
}
$(document).ready(function() {
$("#loginbtn2").click(function() {
if (!validateText("#USN")) {
return false;
}
if (!validateText("#Password2")) {
return false;
}
$("form#students_form").submit();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<link rel="icon" type="/WP Project/image/png" href="/bmsce.png">
<title>BMS Login Page</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
<style>
.one:hover {
color: red;
}
.modal-backdrop {
z-index: -1;
}
h4 {
cursor: pointer;
}
</style>

</head>

<body>
<h4 data-toggle="modal" data-target="#modal">
LOGIN
</h4>
<div class="modal fade" id="modal" tabindex="-1" aria-labelledby="Modal" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close one" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<div class="modal-title" id="ModalLabel">
<div align="center">
<img src="/WP Project/bmsce.png" width="150px" height="150px" />
</div>
</div>
</div>
<div class="modal-body">
<ul class="nav nav-tabs">
<li class="active"><a class="btn btn-danger" data-toggle="tab" href="#students">Students</a>
</li>

</ul>
<br />
<div class="tab-content">
<div class="tab-pane active" id="students">
<div class="well">
<form role="form" action="" id="students_form" method="post">
<div class="form-group">
<label class="control-label" for="USN" id="students_form">Username</label>
<div class="input-group">
<input type="text" class="form-control" id="USN" placeholder="Enter USN" name="username" size=30 aria-describedby="PasswordStatus" />


</div>
</div>
<div class="form-group">
<label for="Password2">Password</label>
<div class="input-group">
<input type="password" class="form-control" id="Password2" placeholder="Password" name="password" size=30 />


</div>
</div>
<hr />
<p>
<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-arrow-left"></span>Back</button>
<button type="button" class="btn btn-primary" id="loginbtn2"><span class="glyphicon glyphicon-lock"></span>Sign in</button>
<br />
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="Scripts/jquery-2.1.3.min.js"></script>
<script src="validate.js"></script>
<script>
$(document).ready(function() {
$('#modal').modal({
backdrop: 'static',
keyboard: false,
show: false
});
});
</script>

<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>

</html>

最佳答案

您已在一个 HTML 文件中包含两个 jQuery 版本。去除 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>从上面你的 DocType 声明

关于javascript - jquery 文件未与 html 文件链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29620012/

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