HTML <button> 无效

本文介绍了HTML中&lt;button&gt;标签的disabled属性及其使用方法。disabled属性用于禁用按钮,使其不可用且不可点击。文章还展示了如何通过JavaScript控制按钮的状态。

HTML <button> 标签的 disabled 属性

定义和用法

disabled 属性规定禁用按钮。

被禁用的按钮既不可用,也不可点击。

可以设置 disabled 属性,直到满足某些条件(比如选择一个复选框),才恢复用户对该按钮的使用。然后,可以使用 JavaScript 来清除 disabled 属性,以使文本区变为可用状态。

实例

一个被禁用的按钮:

<button type="button" disabled="disabled">Click Me!</button>

TIY

语法

<button disabled="value">

属性值

描述
disabled规定应该禁用该按钮。
<%-- Created by IntelliJ IDEA. User: 87424 Date: 2025/5/30 Time: 13:42 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>用户登录界面</title> </head> <style> body{ font-family: Arial, sans-serif; background-color: #f2f2f2; text-align: center; } .container { width: 300px; padding: 16px; background-color: white; margin: 0 auto; margin-top: 50px; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.1); } input[type=text], input[type=password] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; box-sizing: border-box; } button { background-color: #4CAF50; color: BLUE; padding: 14px 20px; margin: 8px 0; border: none; cursor: pointer; width: 100%; } button:hover { opacity: 0.8; } .extra-buttons { margin-top: 20px; } .extra-buttons button { width: auto; margin: 5px; padding: 10px 20px; } .extra-buttons #changePasswordBtn { background-color: #FFFFFF; } .extra-buttons #registerBtn { background-color: #FFFFFF; } .extra-buttons #adminLoginBtn { background-color: #FFFFFF; } </style> </head> <body> <h2>银行用户登录</h2> <div class="container"> <form action="loginProcess.jsp" method="post"> <label for="username"><b>用户名</b></label> <input type="text" placeholder="请输入用户名" name="username" required> <label for="password"><b>密码</b></label> <input type="password" placeholder="请输入密码" name="password" required> <button type="submit">登录</button> </form> <div class="extra-buttons"> <button id="changePasswordBtn" onclick="location.href='change_password.jsp'">忘记密码</button> <button id="registerBtn" onclick="location.href='register.jsp'">注册</button> <button id="adminLoginBtn" onclick="location.href='admin_login.jsp'">登录管理员账户</button> </div> </div> </body> </html> 显示username和password无效id使用
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值