Return to Snippet

Revision: 57543
at May 31, 2012 07:01 by inreflection7


Updated Code
$.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);

Revision: 57542
at May 31, 2012 06:59 by inreflection7


Initial Code
$.extend($.expr[':'], {
        email: function(em) {
            return $(em).attr("type") === "email";
        }
    });

Initial URL


Initial Description
Extend jQuery :selector types

Ex: $("input:text")
$("input:email")

Initial Title
Extend jQuery selector types

Initial Tags
jquery

Initial Language
JavaScript