Recently made a can reply to the message page, mainly including: @, the expression function, a beginning to use the text field textarea, and finally found that the expression can not be displayed, and later changed to editable Div, add contenteditable= "true" in the Div , then the div can be edited.
<contenteditable= "true"></div>
After choosing an expression or selecting a person, you will often find that the cursor in the editable div disappears, or the location is incorrect, so I found some methods on the Internet, and now summarize the following:
functionSet_focus () {El=document.getelementbyid (' Guestbook_editor '); //El=el[0]; jquery Object goto DOM ObjectEl.focus (); if($.support.msie) {varRange =Document.selection.createRange (); This. Last =range; Range.movetoelementtext (EL); Range.Select (); Document.selection.empty (); //uncheck } Else { varRange =Document.createrange (); Range.selectnodecontents (EL); Range.collapse (false); varSEL =window.getselection (); Sel.removeallranges (); Sel.addrange (range); }}
Call this method to place the cursor at the end of an editable div.
Reference Address: http://chwjbn.blog.163.com/blog/static/1038799201310762620681/
Editable DIV Positions the cursor to the last