/ Published in: JavaScript

Extend jQuery :selector types
Ex: $("input:text")
$("input:email")
Ex: $("input:text")
$("input:email")
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.extend($.expr[':'], { email: function(em) { return $(em).attr("type") === "email"; } }); // ':textall' jQuery pseudo-selector for all text input types // source: http://markdalgleish.com/2011/05/jquery-selector-for-html5-input-types/ (function($) { var types = 'text search number email datetime datetime-local date ' + 'month week time tel url color range'.split(' '), len = types.length; $.expr[':']['textall'] = function(elem) { var type = elem.getAttribute('type'); for (var i = 0; i < len; i++) { if (type === types[i]) { return true; } } return false; }; })(jQuery);
Comments
