导航首页 »  技术教程 »  jQuery简单实现彩色云标签效果示例
jQuery简单实现彩色云标签效果示例 926 2024-02-23   

本文实例讲述了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="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">web标准学习</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">css</a> <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">javascript</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">html5</a>
  <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">canvas</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">video</a> <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">audio</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">jQuery</a>
  <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">jQuerymobile</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">flash</a> <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">firefox</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">chrome</a>
  <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">opera</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">IE9</a> <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">css3.0</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">andriod</a>
  <a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">apple</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">google</a><a href="http://www.gimoo.net/t/1901/5c3d3ea1bf92a.html">jobs</a>
</div>

更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery常用插件及用法总结》、《jQuery常见经典特效汇总》、《jQuery form操作技巧汇总》、《jQuery操作json数据技巧汇总》、《jQuery扩展技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery表格(table)操作技巧汇总》、《jquery中Ajax用法总结》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》

希望本文所述对大家jQuery程序设计有所帮助。



文章评论 (0条)
发表评论
暂无评论,快来抢沙发吧~