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
分享到:
相关推荐
v-for="(item,index) in abilityOptions" :key="index" :label="`${item.abilityNameZh}(${item.abilityId})`" :disabled="item.required===1" :value="item.abilityId"> ``` 在main.js文件中,定义一个Vue...
- **`replace(element[, html])`**: Replaces an element with HTML content. - **`scrollTo(element)`**: Scrolls the document so that an element is visible. - **`select(element, selector)`**: Selects ...
只读:readonly 在data里定义:readonly: true, 然后在input框里加上readonly就可以了。...DOCTYPE html> <html lang=en> <head> <meta charset=UTF-8> <meta name=viewport content
validate that the page in the browser is, in fact, an HTML page. Despite the fact that omitting this check can cause unrecoverable crashes in the driver, there is demand for a mechanism to disable ...
<div class="element" data-aos="fade-in-up"> ``` 3. **初始化aos**:在`<body>`标签的底部或`$(document).ready()`内初始化aos,确保所有DOM元素加载完毕后再执行动画: ```javascript $(document).ready...
Cornerstone 是一个开源的Web DICOM(Digital Imaging and Communications in Medicine)图像查看器库,它提供了在Web浏览器中查看和操作医学影像数据的能力。DICOM是医疗领域广泛使用的标准格式,用于存储、传输和...
and modify certain properties of the element. 默认换行为软回车 (Demo) <br/>Most other editors insert double line returns which can be annoying for clients who are used to editing in ...
disable -> for button, if condition not meet title -> display as tool tip DOM -> doc object model -> allows program and script to access and update content display none ->remove element from dom ex: ...
:disable-transitions="false" @close="handleClose(tag)" > {{ tag }} class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput" size="small" @keyup.enter.native=...
"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),a.each(["Width","Height"],function(c,d){...
opt.add_argument('--disable-gpu') web = Chrome(options=opt) ``` 在上面的代码中,我们首先创建了一个ChromeOptions对象,然后使用add_argument方法添加了无头模式和禁用GPU加速的选项。最后,我们使用这些选项...
index([selector|element]) 数据缓存 data([key],[value]) removeData([name|list])1.7* $.data(ele,[key],[val])1.8- 队列控制 queue(e,[q]) dequeue([queueName]) clearQueue([queueName]) 插件机制 ...
// disable text selection on map cover G.mapCover.onselectstart = function() {return false}; return buttonContainerDiv; }; DragZoomControl.prototype.getDefaultPosition = function() { return ...
self.driver.find_element_by_class_name('shark-pager-next').click() # 结束时关闭文件 self.file_name.write("\n]") self.file_name.close() # 实例化爬虫并运行 spider = DouyuSpider() spider.run() ``` ...