button标签disabled以后,click事件就无效了。而span标签disabled以后,click事件还是有效的!
如下代码,用来测试:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>禁用测试</title>
<script src="js/jquery-3.3.1.min.js" type="text/javascript"></script>
</head>
<body>
<div>
<input id="mybtn" type="button" value="clickme"/>
<span id="num">0</span><br/>
<span id="myspan">clickme</span>
</div>
</body>
<
本文探讨了在HTML中,button标签的disabled属性会导致click事件失效,而span标签即使disabled,click事件仍然有效。文章通过示例代码展示了如何实现span标签的禁用和解禁功能。
最低0.47元/天 解锁文章
1179

被折叠的 条评论
为什么被折叠?



