Last active
August 29, 2015 13:58
-
-
Save peterwilsoncc/10085200 to your computer and use it in GitHub Desktop.
jQuery selector: inputs that have fallen back to type="text"
This file contains 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
/* | |
* $( 'input[type=datetime]' ) selects the inputs regardless | |
* of the browsers understanding, as does the equivlent CSS | |
* | |
* The custom selectors below select the inputs based on the | |
* fallback, rather than the attribute | |
* | |
* USE | |
* $( 'input:textprop' ); // select inputs displaying as type=text | |
* $( 'input:nottextprop' ); // select inputs not displaying as type=text | |
*/ | |
jQuery.extend(jQuery.expr[':'],{ | |
textprop: function(el) { | |
return jQuery(el).prop('type') === 'text'; | |
}, | |
nottextprop: function(el) { | |
return jQuery(el).prop('type') !== 'text'; | |
} | |
// be nice to add something here that detected | |
// only HTML5 inputs that had fallen back | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
These are probably not very efficient.