Chrome determines whether to click the label on the input to implement other labels. chromeinput
Function to be implemented: when the input box is out of focus and the key is not cleared, run the reset method to reset the input style. When you click the clear key, run the clear method to clear the input content.
The following code is intended for implementation:
$ (". Search-input"). focusout (function () {if (document. activeElement. className! = 'Close-t') {// close-t indicates the name of the clearing key class $ ('. search-input '). addClass ('search-before'); values ('.close').css ('display', 'None'); document. getElementById ('search '). value = '';}});
When the inpu box is out of focus, the first thing that gets the focus is the body tag. Because of this, the method fails and the following code is used to implement this function.
$ ("# Search "). focusout (function () {// check whether the Clear button is clicked after the focal loss. If yes, var tapCloseButton = false is not reset; $ ('. close-t '). focus (function () {tapCloseButton = true ;}); setTimeout (function () {if (! TapCloseButton) {$ ('. search-input '). addClass ('search-before'); values ('.close').css ('display', 'None'); document. getElementById ('search '). value = ''; }}, 10 );});
The focus judgment step is delayed, so the focus has been moved from the body to the actually clicked element, and then the focus is determined to see if it is a clearing key.
The above chrome judges whether to click the input label or the implementation method of the remaining labels is all the content shared by the editor. I hope to give you a reference, and I hope you can provide more support to the customer's house.