尝试在一个简单的javaweb项目中使用jquery但是没有效果
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>商品管理系统title>
<script type="text/javascript" src="/jquery-3.6.0.js">script>
<script type="text/javascript">
$(document).ready(function () {
$("#toRegistBtn").click(function () {
$(this).hide();
})
});
script>
head>
<body>
<form action="">
<div id="welcome">商品管理系统欢迎您!div>
用户名:<input type="text" name="username"><br>
密码:<input type="text" name="password"><br>
<input type="submit" value="登录"><button type="button" id="toRegistBtn">注册button>
form>
body>
html>
关闭标签对,这个看着少了一个括号呢
<script type="text/javascript" src="/jquery-3.6.0.js">script>
路径不对吧,你改成./jquery-3.6.0.js看看,或者直接改为https://code.jquery.com/jquery-3.6.0.js
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.js">script>
1:/根目录,还不如不要。。就是相对目录
2:js通常和css配合,你这里好像什么都没