文章目錄

注意需要引入jquery

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function shakeTopText(id){
$(id).css("color", randomColor());
}

function loadTopText(id, time) {
setInterval("shakeTopText('"+id+"')", time);
}

function randomColor() {
var R = parseInt(255 * Math.random());
var G = parseInt(255 * Math.random());
var B = parseInt(255 * Math.random());
R = R.toString(16);
G = G.toString(16);
B = B.toString(16);
if (R.length == 1)R = "0" + R;
if (G.length == 1)G = "0" + G;
if (B.length == 1)B = "0" + B;
return("#" + R + G + B);
}
window.onload=function(){
loadTopText("#wyj",500);

}

文章目錄