Posted in Javascript onAugust 01, 2016
本文实例讲述了jQuery简单实现彩色云标签效果的方法。分享给大家供大家参考,具体如下:
一、JS Code:
<script type="text/javascript"> $(function () { randomCloudLabel(); }); function randomCloudLabel() { var obj = $("#CloudLabel a"); function rand(num) { return parseInt(Math.random() * num + 1); } function randomcolor() { var str = Math.ceil(Math.random() * 16777215).toString(16); if (str.length < 6) { str = "0" + str; } return str; } for (len = obj.length, i = len; i--; ) { obj[i].style.left = rand(600) + "px"; obj[i].style.top = rand(400) + "px"; obj[i].className = "color" + rand(5); obj[i].style.zIndex = rand(5); obj[i].style.fontSize = rand(50) + 12 + "px"; obj[i].style.color = "#" + randomcolor(); } } </script>
二、Html Code:
<div id="CloudLabel"> <a href="#">web标准学习</a><a href="#">css</a> <a href="#">javascript</a><a href="#">html5</a> <a href="#">canvas</a><a href="#">video</a> <a href="#">audio</a><a href="#">jQuery</a> <a href="#">jQuerymobile</a><a href="#">flash</a> <a href="#">firefox</a><a href="#">chrome</a> <a href="#">opera</a><a href="#">IE9</a> <a href="#">css3.0</a><a href="#">andriod</a> <a href="#">apple</a><a href="#">google</a><a href="#">jobs</a> </div>
希望本文所述对大家jQuery程序设计有所帮助。
jQuery简单实现彩色云标签效果示例
- Author -
Quber声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@