Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add class to random element

setRandomClass();
setInterval(function () {
    setRandomClass();
}, 2000);//number of milliseconds (2000 = 2 seconds)

function setRandomClass() {
    var ul = $("ul");
    var items = ul.find("li");
    var number = items.length;
    var random = Math.floor((Math.random() * number));
    items.removeClass("special");
    items.eq(random).addClass("special");
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to add theme attribute to :root 
Javascript :: generate tabuada java script 
Javascript :: how to make random responses 
Javascript :: append string in variable using jquery in each loop 
Javascript :: extract values from a column in json format python 
Javascript :: npm can i use my modules without specifying the path 
Javascript :: how does a dictionary from c# translate into js 
Javascript :: how does URL.createObjectURl differ from fileReader 
Javascript :: node.js wikipedia api call 
Javascript :: paypal cordova can not open popup window - blocked 
Javascript :: checkPalindrome 
Javascript :: javascript play many background music 
Javascript :: how to install reveal.js from node 
Javascript :: create react element with string 
Javascript :: firebase remove not valid token 
Javascript :: elements under p5 canvas 
Javascript :: array of in javascript 
Javascript :: show data of mongoose in html page using ejs 
Javascript :: No provider for HTTP! { HTTP Native} 
Javascript :: how to use ternary operatiion in sequelize join statement 
Javascript :: angular sumar labels 
Javascript :: Regular Expressions: Find More Than the First Match 
Javascript :: mongoose virtual populate paginat 
Javascript :: How to pass a map from controller to javascript function in VF page 
Javascript :: refresh javascript using require 
Javascript :: advanced data manipulation javascript 
Javascript :: $(document).ready( function(){ $("#titolo").append(" Ciao").FadeIn(1500); } ); 
Javascript :: JS glob to regex 
Javascript :: alaa 201 exam 
Javascript :: jquerybuilder input date 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =