If you would like to present an information to your user on how much time did he or she spend on your webpage, then here is a particular example on how to do this the easiest way I found.
Class manipulation methods in jQuery are really handy, but when you need just them and nothing else out of jQuery, then using entire library seems like a little bit mistake. Using own versions of
hasClass sounds like a better idea and for this reason I have wrote following article, where you’ll find an example implementation of these methods.
onChange but also to
onKeyPress events. Why? There is a rare situation, where user selects value by clicking dropdown and then using keyboard’s cursor up or cursor down keys.
onKeyPress event will be fired in this situation instead of
onChange event. And desired effect won’t work, if you put it only to
onChange event handler.
This article discusses using of ternary operator, a very usful yet not so famous, logic operator (