📜  冻结输入文本 css 代码示例

📅  最后修改于: 2022-03-11 14:47:46.655000             🧑  作者: Mango

代码示例2
/*
You can't disable anything with CSS, that's a functional-issue. 
CSS is meant for design-issues. You could give the impression of 
a textbox being disabled, by setting washed-out colors on it.

To actually disable the element, you should use the disabled boolean 
attribute: http://jsfiddle.net/p6rja/
*/
 
 /*Or, if you like, you can set this via JavaScript: 
  http://jsfiddle.net/655Su/ */
  document.forms['formName']['inputName'].disabled = true;
/*exp */
/* Keep in mind that disabled inputs won't pass their values through when you post data back to the server. If you want to hold the data, but disallow to directly edit it, you may be interested in setting it to readonly instead. Demo: http://jsfiddle.net/655Su/1/ */ /* Similar to */ document.forms['formName']['inputName'].readOnly = true; /* This doesn't change the UI of the element, so you would need to do that yourself: */ input[readonly] { background: #CCC; color: #333; border: 1px solid #666 } /* You could also target any disabled element: */ input[disabled] { /* styles */ pointer-events: none; } /* https://stackoverflow.com/questions/2458595/disable-a-textbox-using-css */