jQuery: aggiungere il supporto al selettore nth-of-type

jQuery: aggiungere il supporto al selettore nth-of-type

jQuery supporta alcuni selettori del tipo nth- ma non tutti. Ecco come possiamo aggiungere il supporto al selettore nth-of-type utilizzando un selettore custom.

Il codice รจ il seguente:


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