<input type="button" value="返回" onclick="window.location.href='list.jsp'">
时间: 2023-12-23 07:04:27 浏览: 33
以下是一个示例,演示了如何使用HTML中的按钮元素和JavaScript来实现点击按钮返回到指定页面的功能:
```html
<input type="button" value="返回" onclick="window.location.href='list.jsp'">
```
当用户点击这个按钮时,`onclick`事件会触发,JavaScript代码`window.location.href='list.jsp'`会将当前页面的URL重定向到`list.jsp`页面。
相关问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form name="f1"> <textarea name="t1"></textarea> <br> <input type="button" value="启用" onclick="document.f1.t1.disabled=false;"> <input type="button" value="禁用" onclick="document.f1.t1.disabled=true;"> </form> </body> </html>如何让这段代码的按钮点击之后就变色
可以通过在按钮的onclick事件中添加JavaScript代码来实现按钮点击之后变色的效果,具体代码如下:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form name="f1">
<textarea name="t1"></textarea>
<br>
<input type="button" value="启用" onclick="document.f1.t1.disabled=false;this.style.backgroundColor='red'">
<input type="button" value="禁用" onclick="document.f1.t1.disabled=true;this.style.backgroundColor='green'">
</form>
</body>
</html>
```
在启用按钮和禁用按钮的onclick事件中,添加了this.style.backgroundColor='red'和this.style.backgroundColor='green'代码,分别表示按钮点击之后将按钮的背景颜色修改为红色和绿色。这样就可以实现按钮点击之后变色的效果了。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>仓库管理系统</title> <link rel="stylesheet" href="style.css"> </head> <body> <h1>仓库管理系统</h1> <form> <label>仓库名称:</label> <input type="text" id="name"> <label>库存数量:</label> <input type="number" id="quantity"> <button type="button" onclick="addWarehouse()">添加仓库</button> <button type="button" onclick="updateWarehouse()">更新仓库</button> <button type="button" onclick="deleteWarehouse()">删除仓库</button> </form> <hr> <h2>仓库列表</h2> <ul id="warehouseList"></ul> <script src="script.js"></script> </body> </html>给这段代码添加注释
下面是对该 HTML 代码进行注释的版本:
```
<!DOCTYPE html>
<html>
<head>
<!-- 设置字符集为 UTF-8,以支持显示中文等非 ASCII 字符 -->
<meta charset="UTF-8">
<!-- 设置页面标题 -->
<title>仓库管理系统</title>
<!-- 引入样式表 -->
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- 一级标题 -->
<h1>仓库管理系统</h1>
<!-- 表单,用于添加、更新和删除仓库 -->
<form>
<!-- 仓库名称输入框 -->
<label>仓库名称:</label>
<input type="text" id="name">
<!-- 库存数量输入框 -->
<label>库存数量:</label>
<input type="number" id="quantity">
<!-- 添加、更新和删除仓库的按钮 -->
<button type="button" onclick="addWarehouse()">添加仓库</button>
<button type="button" onclick="updateWarehouse()">更新仓库</button>
<button type="button" onclick="deleteWarehouse()">删除仓库</button>
</form>
<!-- 水平分割线 -->
<hr>
<!-- 二级标题 -->
<h2>仓库列表</h2>
<!-- 用于显示所有仓库信息的无序列表 -->
<ul id="warehouseList"></ul>
<!-- 引入 JavaScript 文件 -->
<script src="script.js"></script>
</body>
</html>
```
注释会帮助开发者更好地理解代码,以及在之后修改代码时更容易维护。