Due to the fact that compatibility is not considered, today we are experiencing this problem:
<HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Document</title></Head><Body> <textareaname=""ID=""cols= "+"rows= "Ten"readOnly=true>Sdfasdfadsfasdf</textarea> <Scriptsrc= "Jquery-1.9.1.js"></Script> <Scripttype= "Text/javascript"> $(function(){ $('textarea'). On ('Click',function(){ //$ (this). attr (' readOnly ', false); $( This). CSS ('Background-color','Transparent') var$textarea=$( This); /** SetTimeout (function () {$textarea. focus (); }, 0); **/ $( This). attr ('contenteditable',true); //$ (this). focus (); }); $('textarea'). On ('Blur',function(){ $( This). attr ('readOnly',true); $( This). CSS ('Background-color','#666') }); }); </Script></Body></HTML>
The desired effect is a direct click to get the cursor and enter the characters in the textarea. But focus is not effective in IE. looking everywhere, or on the powerful stackoverflow found the answer.
The first: direct use of the Select () method without focus () but there is a serious problem with interactivity.
The second kind: StackOverflow above a solution is to use the above annotated settimeout event, I tried, not the effect. "A successful friend does not have the trouble to enlighten."
The Third kind: is still in StackOverflow, the above questioner last used is $ (this). attr (' contenteditable ', true); Contenteditable This property, this effect can be achieved. But only in IE effective, this special processing can be. This should be the best solution.
StackOverflow Links:
Http://stackoverflow.com/questions/9806910/textarea-is-not-editable-not-readonly-in-ie
Http://stackoverflow.com/questions/3764440/ie-readonly-textarea-problem
TextArea focus doesn't work in IE