Show Random ads using jQuery Tutorial!

This post teaches you how to show different ads each time when a user refresh the page. It’s very simple using jQuery and If you see the number of lines of code It’s only 5 Lines!

Copy and Paste the below code and give the path of the images or script to display random ads:

<script src=""></script>
<script type="text/javascript">
var divs = $("").get().sort(function(){
return Math.round(Math.random());
<!--Between <div class="ads"> tag you can also use ad scripts!. Eg: adsense ads-->
<div class="ads"><a href=""><img src="ads/ad1.jpg" border="0" /></a></div>
<div class="ads"><a href=""><img src="ads/ad2.jpg" border="0" /></a></div>
<div class="ads"><a href=""><img src="ads/ad3.jpg" border="0" /></a></div>
<div class="ads"><a href=""><img src="ads/ad4.jpg" border="0" /></a></div>
<div class="ads"><a href=""><img src="ads/ad5.jpg" border="0" /></a></div>

Here is the demo for your convenience:


About the Author


Software Engineer, Blogger etc., Visit my Youtube channel - <a href="">Click Here</a>

2 thoughts on “Show Random ads using jQuery Tutorial!

Leave a Reply

Your email address will not be published. Required fields are marked *