在 jQuery 中添加 :nth-of-type

Avatar of Chris Coyier
Chris Coyier
$.expr[':']['nth-of-type'] = function(elem, i, match) {
    var parts = match[3].split("+");
    return (i + 1 - (parts[1] || 0)) % parseInt(parts[0], 10) === 0;
};

查看 原文,获取有关添加其他“of type”选择器的更多信息。