Rumah >hujung hadapan web >html tutorial >怎么样向css中添加随机文字?_html/css_WEB-ITnose
如已经生成9个li,我想随机在内容前面加:
<script></script>
<script> <br /> $(function(){ <br /> var array1=["老大","老2","老3"]; <br /> $("li").each(function(){ <br /> var idx=Math.round(Math.random()*2); <br /> var str=array1[idx]; <br /> $(this).prepend(str); <br /> }); <br /> }); <br /> </script>
<script></script>
<script> <br /> $(function(){ <br /> var array1=["老大","老2","老3"]; <br /> $("li").each(function(){ <br /> var idx=Math.round(Math.random()*2); <br /> var str=array1[idx]; <br /> $(this).prepend(str); <br /> }); <br /> }); <br /> </script>