jQuery umožňuje pridávať vlastné pseudo-selektory. To sa dá jednoducho docieliť pridaním funkcie do $.expr[':'] objektu.
(function($){
var random = 0;
$.expr[':'].random = function(a, i, m, r) {
if (i == 0) {
random = Math.floor(Math.random() * r.length);
}
return i == random;
};
})(jQuery);
A ako to použiť:
$('li:random').addClass('glow');
© 2009 Shaddow
hosting od VIPHosting