I have a page that looks like
<a href="#" onclick="go('register')">
<img class="img" src="img/192.webp" alt="box set" />
<div class="name" style="line-height: 2">box set</div>
</a>
</div>
<div class="item ">
<a href="#" onclick="go('register')">
<img class="img" src="img/182.webp" alt="battery" />
<div class="name" style="line-height: 2">battery</div>
I was wondering if there is a way that I could insert a div class randomly “percentx” (random between 1-100), so when the page is loaded, it would look like:
<a href="#" onclick="go('register')">
<img class="img" src="img/192.webp" alt="box set" />
<div class="name" style="line-height: 2">box set</div>
<div class="percent75"></div>
</a>
</div>
<div class="item ">
<a href="#" onclick="go('register')">
<img class="img" src="img/182.webp" alt="battery" />
<div class="name" style="line-height: 2">battery</div>
<div class="percent61"></div>
Then change every 60 second
<a href="#" onclick="go('register')">
<img class="img" src="img/192.webp" alt="box set" />
<div class="name" style="line-height: 2">box set</div>
<div class="percent21"></div>
</a>
</div>
<div class="item ">
<a href="#" onclick="go('register')">
<img class="img" src="img/182.webp" alt="battery" />
<div class="name" style="line-height: 2">battery</div>
<div class="percent95"></div>
Regarding this thread
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="percent"></div>
$('.percent').each(function () {
var x = Math.floor((Math.random() * 100) + 1);
$(this).text(x)
});
Honestly I have no idea how to make this works, any helps would highly apreciated.