[Javascript] 01. & lt; script & gt; 02. // specify ument. getElementById (myid). focus (); // obtain the focus...
[Javascript]
01. script
02. // when the intersection is lost, the text in the text box will be focused and the cursor will move to the end of the last word.
03. function myfocus (myid ){
04. if (isNav ){
05. document. getElementById (myid). focus (); // obtain the focus
06.
07.} else {
08. setFocus. call (document. getElementById (myid ));
09 .}
10 .}
11. var isNav = (window. navigator. appName. toLowerCase (). indexOf ("netscape")> = 0 );
12. var isIE = (window. navigator. appName. toLowerCase (). indexOf ("microsoft")> = 0 );
13. function setFocus (){
14. var range = this. createTextRange (); // create a Text Selection
15. range. moveStart ('character ', this. value. length); // move the start point of the selection to the end.
16. range. collapse (true );
17. range. select ();
18 .}
19. script
Script
// When the intersection is lost, the text in the text box will be focused and the cursor will move to the end of the last word.
Function myfocus (myid ){
If (isNav ){
Document. getElementById (myid). focus (); // obtain the focus
} Else {
SetFocus. call (document. getElementById (myid ));
}
}
Var isNav = (window. navigator. appName. toLowerCase (). indexOf ("netscape")> = 0 );
Var isIE = (window. navigator. appName. toLowerCase (). indexOf ("microsoft")> = 0 );
Function setFocus (){
Var range = this. createTextRange (); // create a Text Selection
Range. moveStart ('character ', this. value. length); // move the start point of the selection to the end.
Range. collapse (true );
Range. select ();
}
Script
The fuzzy search of ztree is used here.
At the beginning, all Tree nodes are closed. However, if you enter the search content for a query, after expanding the parent node of the query content, the focus in the input will be lost, the user experience is not good. Here, after the parent node is expanded, let the input get the focus. If only focus () is used, the cursor will appear at the beginning of the text box. Of course, this is not what I want. By calling the code above, you can locate the query text behind the cursor after the query.