<!DOCTYPE html> <html> <head> <title>文档标题</title> <style> input { font-size: 40px; } body { font-size: 40px; } select { font-size: 40px; } </style> <script type="text/javascript"> function fun() { var num = document.getElementById("num").value; if (num % 2 == 0) { return true; } else { return false; } } </script> <script type="text/javascript"> window.onload = function () { var num = Math.floor(Math.random() * 10001); document.getElementById("num").value = num; } </script> </head> <body> <div id="div1"> 请输入数字<br> <input type="text" name="num" id=num> <input type="button" onclick="fun()" value="判断奇偶性" /> </div> </body> </html>
时间: 2024-02-14 12:05:59 浏览: 14
这是一个使用 HTML、CSS 和 JavaScript 编写的简单网页,包含一个输入框、一个按钮和一些样式设置。当用户输入一个数字并点击按钮时,JavaScript 代码会判断该数字的奇偶性并返回结果。其中,HTML 代码用于定义页面结构,CSS 代码用于设置页面样式,JavaScript 代码用于实现页面交互。页面加载时,JavaScript 代码会生成一个随机数并将其填充到输入框中。
相关问题
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>酒店管理系统</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <h1>酒店管理系统</h1> </header> <main> <h2>酒店客房管理</h2> <table> <thead> <tr> <th>ID</th> <th>类型</th> <th>价格</th> <th>编辑</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>单人房</td> <td>¥200</td> <td><button class="edit-btn">编辑</button></td> </tr> <tr> <td>2</td> <td>双人房</td> <td>¥300</td> <td><button class="edit-btn">编辑</button></td> </tr> <tr> <td>3</td> <td>豪华房</td> <td>¥500</td> <td><button class="edit-btn">编辑</button></td> </tr> </tbody> </table> <div class="add-form"> <h3>添加客房</h3> <form> <div> <label for="room-id">ID:</label> <input type="number" id="room-id" required> </div> <div> <label for="room-type">类型:</label> <input type="text" id="room-type" required> </div> <div> <label for="room-price">价格:</label> <input type="number" id="room-price" required> </div> <button type="submit">添加</button> </form> </div> </main> <script src="script.js"></script> </body> </html>给代码逐行加上注释
<!DOCTYPE html> <!-- 声明文档类型 -->
<html>
<head>
<meta charset="UTF-8"> <!-- 设置字符编码为UTF-8 -->
<title>酒店管理系统</title> <!-- 设置网页标题 -->
<link rel="stylesheet" href="style.css"> <!-- 引入外部样式表 -->
</head>
<body>
<header> <!-- 设置网页头部 -->
<h1>酒店管理系统</h1> <!-- 设置网页标题 -->
</header>
<main> <!-- 设置网页主体内容 -->
<h2>酒店客房管理</h2> <!-- 设置主体内容标题 -->
<table> <!-- 创建表格 -->
<thead> <!-- 设置表格头部 -->
<tr> <!-- 创建表格行 -->
<th>ID</th> <!-- 创建表格头部单元格 -->
<th>类型</th>
<th>价格</th>
<th>编辑</th>
</tr>
</thead>
<tbody> <!-- 设置表格内容 -->
<tr>
<td>1</td> <!-- 创建表格单元格,并填写内容 -->
<td>单人房</td>
<td>¥200</td>
<td><button class="edit-btn">编辑</button></td> <!-- 创建带有“编辑”按钮的单元格 -->
</tr>
<tr>
<td>2</td>
<td>双人房</td>
<td>¥300</td>
<td><button class="edit-btn">编辑</button></td>
</tr>
<tr>
<td>3</td>
<td>豪华房</td>
<td>¥500</td>
<td><button class="edit-btn">编辑</button></td>
</tr>
</tbody>
</table>
<div class="add-form"> <!-- 创建添加客房的表单 -->
<h3>添加客房</h3> <!-- 设置表单标题 -->
<form> <!-- 创建表单 -->
<div>
<label for="room-id">ID:</label> <!-- 创建表单标签和输入框 -->
<input type="number" id="room-id" required> <!-- 设置输入框类型为数字,且必填 -->
</div>
<div>
<label for="room-type">类型:</label>
<input type="text" id="room-type" required> <!-- 设置输入框类型为文本,且必填 -->
</div>
<div>
<label for="room-price">价格:</label>
<input type="number" id="room-price" required>
</div>
<button type="submit">添加</button> <!-- 创建提交按钮 -->
</form>
</div>
</main>
<script src="script.js"></script> <!-- 引入外部JavaScript文件 -->
</body>
</html>
完成程序,实现购物车计算器的功能。 参考Html代码如下,可根据需求进行修改: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> </head> <body> <h3>购物车计算器</h3> <label>单价:</label><input type="text"><br/> <label>数量:</label><input type="text"><br/> <label>应付金额:<
/label> <span id="totalPrice"></span><br/> <button onclick="calculate()">计算</button> <script> function calculate() { var price = parseFloat(document.querySelector("input[type=text]:nth-of-type(1)").value); var quantity = parseInt(document.querySelector("input[type=text]:nth-of-type(2)").value); var totalPrice = price * quantity; document.getElementById("totalPrice").innerHTML = totalPrice.toFixed(2); } </script> </body> </html>
注:该程序只实现了简单的购物车计算器功能,可以根据自己的需求进行修改和完善。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
样式优化美化<!DOCTYPE html> {% load static %} <html> <head> <title>个人中心</title> <style> .container { display: flex; flex-wrap: wrap; justify-content: space-between; } .module { width: calc(25% - 20px); margin-bottom: 20px; padding: 20px; border: 1px solid #ccc; border-radius: 5px; } @media (max-width: 768px) { .module { width: calc(50% - 20px); } } @media (max-width: 480px) { .module { width: 100%; } } </style> </head> <body> 个人信息 <form> <label for="username">用户名:</label> <input type="text" id="username"> <label for="email">邮箱:</label> <input type="email" id="email"> <button type="submit">保存</button> </form> 修改密码 <form> <label for="old-password">旧密码:</label> <input type="password" id="old-password"> <label for="new-password">新密码:</label> <input type="password" id="new-password"> <label for="confirm-password">确认密码:</label> <input type="password" id="confirm-password"> <button type="submit">保存</button> </form> 绑定手机 <form> <label for="phone">手机号:</label> <input type="tel" id="phone"> <button type="submit">保存</button> </form> 我的消息 系统消息1 系统消息2 好友消息1 好友消息2 </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
請你幫我美化重新佈局這段代碼<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>异常记录</title> <style> </style> </head> <body> 首页 登记数据 查询数据 异常记录登记 <form method="post" action="/submit"> <label>确认线别:</label> <input type="text" name="line"> <label>确认日期:</label> <input type="date" name="date"> <label>异常机种:</label> <input type="text" name="model"> <label>异常现象:</label> <input type="text" name="prod_line"> <label>生产日期:</label> <input type="date" name="prod_date"> <label>生产班别:</label> <input type="text" name="shift"> <label>生产线别:</label> <input type="text" name="prod_line"> <label>责任人:</label> <input type="text" name="responsible"> <input type="submit" value="提交"> </form> </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
請你幫我打修改HTML代碼<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>异常记录</title> <style> .main { display: flex; flex-direction: row; justify-content: space-between; align-items: center; } </style> </head> <body> 首页 登记数据 查询数据 异常记录登记 <form method="post" action="/submit"> <label>确认线别:</label> <input type="text" name="line">
<label>确认日期:</label> <input type="date" name="date">
<label>异常机种:</label> <input type="text" name="model">
<label>异常现象:</label> <textarea name="issue"></textarea>
<label>生产日期:</label> <input type="date" name="prod_date">
<label>生产班别:</label> <input type="text" name="shift">
<label>生产线别:</label> <input type="text" name="prod_line">
<label>责任人:</label> <input type="text" name="responsible">
<input type="submit" value="提交"> </form> 欢迎访问 </body> </html>
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)