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>

JavaScript

var elem = $("#banners a");
var img1 = Math.floor(Math.random() * elem.length), 
    img2 = Math.floor(Math.random() * elem.length);

while (img1===img2) {
  img2 = Math.floor(Math.random() * elem.length);
}

elem.hide();
elem.eq(img1).show();
elem.eq(img2).show();