Home > front end >  How to prevent text box focus again from cross word pops up when the mouse icon bar after moving bac
How to prevent text box focus again from cross word pops up when the mouse icon bar after moving bac

Time:12-13

The first script, when the mouse moves to input, textarea element text box, automatic focusing, the cursor at the end of the text, removed from the input, the textarea automatically out-of-focus

Another script, cross word play icon bar

Move the mouse from icon bar to text box, or click the icon to perform functions, such as copying, icon bar disappear automatically after the mouse in the text box, automatically revisit the text box, cross word words will disappear, the cursor at the end of the text

How to make the mouse from the icon bar, move back to the text box is no longer automatic focusing, zoned reserved word words

The monkey has a way of thinking, the use of oil storage element of the location of the mouse, move to the next is one of the elements is the img element judgment, not automatic focusing, from input, textarea element to the img element to remove out-of-focus timing

Don't know how to store the elements, as the next judgment

Icon bar element e. arget. LocalName==='img'

Cross word play icon bar tool

//automatic focusing 
Document. The addEventListener (' mouseover, function (e) {
If (e. arget. LocalName==='input' | | e. arget. LocalName==='textarea') {
E. arget. Focus ();
Var val=e. arget. Value;//store the value of the element
e.target.valuehttps://bbs.csdn.net/topics/=';//clear the value of the element
E. arget. Value=https://bbs.csdn.net/topics/val;//set that value back.
}
});
//out-of-focus
Document. The addEventListener (' mouseout ', function (e) {
Var text=window. GetSelection (). The toString (). The trim ();
The timer=setTimeout (function () {
E. arget. The blur ();
}, 20)
If (text) {
ClearTimeout (timer);
}
},false);



  • Related