Randomly Displayed Content Using CSS and JavaScript
This script takes an unordered list and randomly displays one item on each page load (reload to test).
Did you know that...
- ... if you want to become a better coder you need to eat your vegetables?
- ... it takes more time to code a web page then to make a pizza?
- ... you should validate your code?
- ... jQuery is your friend? For real!
- ... no matter what some people claim, you can't learn CSS in 3 hours?
The Script
this.randomtip = function(){
var length = $("#tips li").length;
var ran = Math.floor(Math.random()*length) + 1;
$("#tips li:nth-child(" + ran + ")").show();
};
$(document).ready(function(){
randomtip();
});
Go back to the article
This script is supported by Css Templates by Templatica