disabled attribute
This Boolean attribute indicates that the form control is not available for interaction. In particular, the click event will not be dispatched on disabled controls. Also, a disabled control's value isn't submitted with the form.
This attribute is ignored if the value of the type attribute is hidden.
eg.
elem.setAttribute("disabled", "disabled");
elem.removeAttribute("disabled");
note:
In HTML boolean attributes such as disabled and readonly can only legally take the name of the attribute.
eg. disabled="disabled" readonly="readonly"
Most browsers however accept any value for the attribute as being in the affimative.
So the following are equivalent:
disabled="disabled"
disabled
disabled="true"
disabled="false"
disabled="unknown"
disabled="23"
disabled="no"
If you want to remove a disabled attribute in script, use the removeAttribute() method or use the origin dom property.
disabled property
eg.
if (elem.disabled) {
elem.disabled = false;
} else {
elem.disabled = true;
}
disable element online demo
<!DOCTYPE html>
<html>
<head>
<title>disable element</title>
<script>
window.onload = function() {
var lname = document.getElementById("lname");
var fname = document.getElementById("fname");
lname.disabled = false;
fname.disabled = true;
}
</script>
</head>
<body>
<form action="#" method="get">
<p>First name: <input id="fname" type="text" name="fname" /></p>
<p>Last name: <input id="lname" type="text" name="lname" /></p>
<input type="submit" value="Submit" />
</form>
</body>
</html>
disable element with jQuery online demo
<!DOCTYPE html>
<html>
<head>
<title>disable element with jquery</title>
<script id="jquery_172" type="text/javascript" class="library" src="/js/sandbox/jquery/jquery-1.7.2.min.js"></script>
<script>
jQuery(function ($) {
var lname = $("#lname");
var fname = $("#fname");
lname[0].disabled = false;
fname[0].disabled = true;
$("#change").click(function() {
var t = fname[0];
if (t.disabled) {
t.disabled = false;
} else {
t.disabled = true;
}
});
});
</script>
</head>
<body>
<form action="#" method="get">
<p>First name: <input id="fname" type="text" name="fname" /></p>
<p>Last name: <input id="lname" type="text" name="lname" /></p>
<input id="change" type="button" value="en/disable" />
</form>
</body>
</html>
ref:
disabled attribute | disabled property
disabled-false-doesn-enable
分享到:
相关推荐
Disable the Return Key in a TextBox
JavaScript
enable and disable "HOME" button in android 4.0.3 above the version 4.0.3,we should modify the frameworks detail is described in the Enable_Disable_Home.rar
蚁剑的能绕过disable_functions的插件,插件无法下载问题
此adb中无adb disable-verity命令,如果在cmd中输入以上命令会报 /system/bin/sh: disable-verity: not found 的错误。具体可看本人的文章 ”/system/bin/sh: disable-verity: not found 的解决方案“ 【使用方式】...
语言:English ...转至Wiki以获取文档,支持信息以及更多信息:https://github.com/Eloston/disable-html5-autoplay/wiki链接:GitHub页面:https://github.com/Eloston/disable-html5-自动播放变更日志:...
禁用所有HTML5音频和视频的...转至Wiki以获取文档,支持信息以及更多信息:https://github.com/Eloston/disable-html5-autoplay/wiki链接:GitHub页面:https://github.com/Eloston/disable-html5-自动播放变更日志:...
NULL 博文链接:https://liang-wenfu.iteye.com/blog/1017556
重新编译的支持adb disable-verity命令的adb,通常用于解锁system分区
后仿
支持adb disable-verity的最新adb工具包。
reg文件zip包,used for disable ULPS。
td00036 华为以太网交换机vlan disable的功能和配置.doc
本文将为大家介绍交换机出现err-disable的原因及解决方法。
此adb工具包中包含了adb disable-verity命令,这里免费提供给大家使用,具体可看本人的文章 ”/system/bin/sh: disable-verity: not found 的解决方案“ 【使用方式】 platform-tools解压后即可使用。在cmd中通过cd...
针对宝塔的RASP及其disable_functions的绕过1
WordPress的插件:google字体插件-disable-google-fonts 解压后,请将目录名称:wordpress1,修改为:disable-google-fonts
Simple.Disable.Key可以修改键盘的热键,进行禁止或者重新组合等,部分电脑可能使用不了,这个具体看自己电脑,慎重下载,这个软件是公认可以修改键盘热键的,可以百度查