Created
September 11, 2011 19:18
-
-
Save lsauer/1209992 to your computer and use it in GitHub Desktop.
OnBlur will not fire when changing onFocus to onKeyUp, onKeyPress, onKeyDown,...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following code will do just what you would expect (a css rule for the element's id is applied). | |
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" /> | |
However when the onClick is changed to onKeyUp, onKeyPress, onKeyDown it will expand but not retract. This is because the element is not marked focused, or because the event order got messed up (in Chrome >12). | |
Include this.focus(); | |
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.focus(); this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment