mardi 27 décembre 2016

random css position jquery

using math.random, I can position the div to the left, randomly. But i need set the "left" and "right" positions randomly.

 jQuery('#popup-container').css({'left' : (Math.floor(Math.random() * 15) + 3) + '%'})
  

Example, in attribute ".css({left", have an randon with "left or right". An array with these positions. how do I do that?




Aucun commentaire:

Enregistrer un commentaire