jQuery-随机加载
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery-随机加载相关的知识,希望对你有一定的参考价值。
<!-- Google jQuery call --> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> // You may specify partial version numbers, such as "1" or "1.3", // with the same result. Doing so will automatically load the // latest version matching that partial revision pattern // (i.e. both 1 and 1.3 would load 1.3.2 today). google.load("jquery", "1.3.2"); google.setOnLoadCallback(function() { // Place init code here instead of $(document).ready() }); </script> <script type="text/javascript"> this.randomtip = function(){ var length = $("#tips li").length; var ran = Math.floor(Math.random()*length) + 1; $("#tips li:nth-child(" + ran + ")").show(); }; $(document).ready(function(){ randomtip(); }); </script> <style type="text/css"> #tips, #tips li{ margin:0; padding:0; list-style:none; } #tips{ width:250px; font-size:16px; line-height:120%; } #tips li{ padding:20px; background:#e1e1e1; display:none; /* hide the items at first only */ } </style> <ul id="tips"> <li>... if you want to become a better coder you need to eat your vegetables?</li> <li>... it takes more time to code a web page then to make a pizza?</li> <li>... you should validate your code?</li> <li>... jQuery is your friend? For real!</li> <li>... no matter what some people claim, you can't learn CSS in 3 hours?</li> </ul>
以上是关于jQuery-随机加载的主要内容,如果未能解决你的问题,请参考以下文章