JSFiddle - React, Tailwind, and code Playground

HTML

<div id="banners">
    <a href="p1.html">1</a>
    <a href="p2.html">2</a>
    <a href="p3.html">3</a>
    <a href="p4.html">4</a>
    <a href="p5.html">5</a>
</div>

<button>Random</button>

JavaScript

function randomize() {
    var allBanners = $('#banners a');
    allBanners.hide();
    
    var index = Math.floor(Math.random() * allBanners.length);
    allBanners.eq(index).show();
    
    var index2 = Math.floor(Math.random() * allBanners.length - 1);
    allBanners.not(allBanners.eq(index)).eq(index2).show();
}

$('button').click(randomize);
randomize();