Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** AB testing **/
- jQuery('.ab-testing > *').css({'display':'none'});
- jQuery('.ab-testing').each(function() {
- var $els = jQuery(this).find('>*');
- var slots = [];
- var i = -1;
- $els.each(function() {
- i++;
- var nbSlots = (jQuery(this).attr('slots')||1)*1;
- for (var j=0; j<nbSlots; j++)
- slots.push(i);
- });
- var iSlot = Math.floor(Math.random()*(slots.length||0));
- var iFinal = slots[iSlot];
- jQuery(this).find('>*:eq('+iFinal+')').css({'display':''}).addClass('ab-ok');
- jQuery(this).find('>*:not(.ab-ok)').remove();
- });
Add Comment
Please, Sign In to add comment