Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwilsoncc/10085200 to your computer and use it in GitHub Desktop.
Save peterwilsoncc/10085200 to your computer and use it in GitHub Desktop.
jQuery selector: inputs that have fallen back to type="text"
/*
* $( '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
});
@peterwilsoncc
Copy link
Author

These are probably not very efficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment