1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| !DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="author" content="" /> <meta name="viewport" content="width=device-width, user-scalable=0, initial-scale=1"> <title>手机webQQ</title> <link rel="stylesheet" href="css/phone.css"> <script src="js/jquery-1.11.2.js"></script> <script src="js/qq.js"></script> </head> <body> <div id="test">我是测试内容!!!</div> <button id="btn">改变颜色</button> <script>
function fRandomBy(under, over){ switch (arguments.length) { case 1: return parseInt(Math.random() * under + 1); case 2: return parseInt(Math.random() * (over - under + 1) + under); default: return 0; } }
var colorArr = [ '#FF6666', '#D366FF', '#FF8166', '#6672FF', '#FF667F', '#9B66FF', '#FF66D8', '#FF6675', '#66B2FF', '#FF8E66', '#FF66F9', '#FF8B66', '#FF7766', '#FF66C6', '#FFC666', '#6866FF', '#FF667C', '#FF7566', '#FF66BC', '#6666FF', '#6696FF', '#FF9666', '#66DDFF', '#669DFF', '#CE66FF', '#66C6FF', '#FFAD66', '#BA66FF', '#8966FF', '#E266FF', '#F466FF', '#FF66BE', '#36F08B', '#66A3FF', '#F166FF', '#66BAFF', '#8E66FF', '#FF6689', '#66AAFF', '#C966FF', '#66A0FF', '#8766FF', '#FA558B', '#66B7FF', '#ED66FF' ];
function randomColor(num){ return colorArr[num]; } window.onload = function(){ document.getElementById('btn').onclick = function() { document.getElementById('test').style.color = randomColor(fRandomBy(0, 30)); } } </script> </body> </html>
|