I'm using the code below to get a random number of items from an array, but I'd like to just get 3-5 random numbers from the provided range to display. Right now, it either shows 1, all, or any amount in between. I'm also good with completely changing up my strategy, so any and all advice is welcome. Much appreciated.
<script type="text/javascript" src="https://fiftyallstars.com/Code/jquery-2.2.4.js"></script>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<script type="text/javascript">
$('div').filter(function(){
return (Math.round(Math.random()) == 1);
}).css({display: 'none'});
</script>
Aucun commentaire:
Enregistrer un commentaire