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 provide 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>

Where will those div values come from? Will it be known fixed (constant) values or dynamic?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.