Created
December 25, 2011 06:42
-
-
Save corymartin/1518824 to your computer and use it in GitHub Desktop.
jQuery pseudo selectors for HTML5 input types
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
| // | |
| // Adds jQuery Pseudo Selectors for HTML5 input types. | |
| // | |
| // Example: | |
| // HTML: | |
| // <input type="email" name="user_email"> | |
| // jQuery: | |
| // $(':email'); | |
| // | |
| // | |
| // Pseudo Selectors: | |
| // :color | |
| // :date | |
| // :datetime | |
| // :datetime-local | |
| // :month | |
| // :number | |
| // :range | |
| // :search | |
| // :tel | |
| // :time | |
| // :url | |
| // :week | |
| // | |
| (function($) { | |
| var types = 'color date datetime datetime-local email month number range search tel time url week'.split(' '); | |
| $.each(types, function(i, type) { | |
| $.expr[':'][type] = function(el) { | |
| return el.nodeName.toUpperCase() === 'INPUT' && el.type === type; | |
| }; | |
| }); | |
| })(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment