readonly:expression(this.readOnly=true); 分类Never Forget
:read-write 返回CSS 选择器CSS :read-only 选择器 CSS :read-only 伪类 表示元素不可被用户编辑的状态(如锁定的文本输入框)。实例 仅当输入元素为“只读”时选择元素并设置样式:<!DOCTYPE html> <html> <head> <style> input:read-only { background-color: yellow; } </style> </head> <body> <h1...
1. 识别需要修改的 readonly 元素的默认样式 首先,你需要确定你想要修改的 readonly 元素的类型(如 input、textarea 等)以及你想要改变的默认样式(如背景色、边框、字体颜色等)。 2. 编写CSS规则以覆盖 readonly 元素的默认样式 使用属性选择器 [readonly] 来选中带有 readonly 属性的元素,并编写相应的CSS规则...
<style type="text/css"> input{ background-color:expression(this.readOnly==true?"#eee":"#fff"); } </style>
input[type="text"]:read-only { background-color:#EEEEEE; } </style> </head> <body> <form> <p><labelfor="text1">读写:</label><inputtype="text"name="text1"/></p> <p><labelfor="text2">只读:</label><inputtype="text"name="text2"readonly="readonly"/></p> ...
<style>input[readonly] //readonly:后台能接收此input框传值{background:#dddddd; //为带有readonly的input框添加背景颜色cursor: not-allowed // 表示一个红色的圈加一个斜杠}</style> 2.鼠标原有的事件不能实现:pointer-events:none 样式演示:
document.querySelector("input[name='number2']").style.cssText = "border: 1px solid red"; }) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 通过上面的测试可以知道,readonly属性只是将元素设置为只读,可以获取焦点、失去焦点。而disabled属性直接...
Css Style 里ReadOnly的设置 <!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> ...
input:read-only { color:green; } </style> </head> <body> <form action="#" method="post"> <input type="text" value="螞蟻部落" readonly><br/> <input type="text" value="螞蟻部落"><br/> <input type="submit" id="bt" value="提交表單"/> ...
document.querySelector("input[name='number2']").style.cssText = "border: 1px solid red"; }) 通过上面的测试可以知道,readonly属性只是将元素设置为只读,可以获取焦点、失去焦点。而disabled属性直接阻止对元素的一切操作。 disabled属性阻止对元素的一切操作,例如获取焦点,点击事件等等。