解决方案一: onfocus="this.defaultIndex=this.selectedIndex;"onchange="this.selectedIndex=this.defaultIndex;" 或者: $("select[readonly=readonly] option").attr("disabled","disabled"); 解决方案一通过js方式来达到目的,但是这样依旧能够看到其它选项。 怎么让其它选项也无法看到呢? 我尝试了用js控制,可是opt...
通常,我们会使用`disabled`属性来禁用一个`<select>`元素,但这会使得整个下拉列表呈灰色不可选状态。而题目中提到的需求是“HTML中Select不用`Disabled`实现`ReadOnly`的效果”,即保持下拉列表可查看,但阻止用户交互。 要实现这种效果,我们可以利用事件处理程序来模拟只读状态,而不直接使用`disabled`属性。以下是实现...
Readonly只针对input(text / password)和textarea有效,而disabled对于所有的表单元素都有效,但是表单元素在使用了disabled后,当我们将表单以POST或GET的方式提交的话,这个元素的值不会被传递出去,而readonly会将该值传递出去(readonly接受值更改可以回传,disable接受改但不回传数据)。 一般比较常用的情况是: 在某个...
<selectonbeforeactivate="return false"onfocus="this.blur()"onmouseover="this.setCapture()"onmouseout="this.releaseCapture()"> <option>1</option> <optionselected>2</option> <option>3</option> </select> </body> </html>
HTML中Select不用Disabled实现ReadOnly的效果 方法如下: 代码如下: <select onbeforeactivate="return false" onfocus="this.blur()" onmouseover="this.setCapture()" onmouseout="this.releaseCapture()"> <option>1</option> </select>
setInput 只读效果实现方法 Disabled 和 Readonly 是两种常见的方法来实现 Input 只读效果,它们均可以使 Input 变为不可编辑状态,但它们之间存在着重要的区别。 Disabled 方法 Disabled 属性用于指定 Input ... 设置disabled属性后台读不到数据如何让select支持readonly 这种方法允许用户看到并选择`<select>`...
1)适应范围: readonly:input[type="text"],input[type="password"],input[type="teaxtarea"] disabled:所有的表单元素,如select, radio, checkbox, button等 2)操作: readonly:不允许用户修改操作,不影响其它的任何操作 disabled:阻止用户一切操作,包括用户点击事件,获取焦点事件 3)表单提交: readonly:表单元素...
刚刚碰到一个要为html select添加readonly属性的要求,可是select是不支持readonly属性的,找了找,方法还是有的,不过大都比较麻烦。以下的方法个人认为是最简单的: <select id="lstTest" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;"> ...
<option vslue = "hubei">湖北省</option> </select> file控件 <form action= " "> 文件:<inpute type = "file"/> <input type = "submit" value = "文件上传"/> </form> readonly和disabled 都是只读的 readonly修饰的表单项可以提交给服务器 ...
A boolean that represents the element's disabled attribute, indicating that the control is not available for interaction. The input values will not be submitted with the form. See also readonly. required A boolean that represents the element's required attribute, indicating that the user must fil...