zoukankan
html css js c++ java
随机显示数字
主要知识点有:
数组的两种新建方式,
Math.random函数的运用
innerHTML与 += 运算符的运用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>豪情</title> </head> <body> <span id="t"></span> <script type="text/javascript"> var texts = new Array('中国', '西安', '上海', '中国', '西安', '上海'); var colors = ['red', 'blue', 'gray', 'orange']; for(var i=0; i<texts.length; i++){ //alert(parseInt(Math.random()*colors.length)); document.getElementById('t').innerHTML += "<span style='font-weight:bold;margin:0 10px;color:" + colors[parseInt(Math.random()*colors.length + 1)] + ";'>" + texts[i] + "</span>"; } </script> </body> </html>
运行代码
查看全文
相关阅读:
BigPipe_高性能流水线页面技术
高并发大流量网站 10 个解决方法
崇高不是比惨
utf-8无bom格式编码
go.php
微信+QQ跳转
java 设计模式-单例
HTML连载88-今天把努比亚界面仿真写完了(完结连载)
Android连载10-动态添加页面、创建一个新闻app
JavaScript连载9-三目运算符、综合复习
原文地址:https://www.cnblogs.com/jikey/p/1756155.html
最新文章
在Grafana中可视化Jenkins管道结果
android permission
ffmpeg compile
C/C++ Connect SQLSERVER
Android std Android.mk && Application.mk
linux unzip .zip file
Android Devloper doc
Android android problem
27 ArrayList 和 Vector 的区别是什么?
26 如何实现数组和 List 之间的转换?
热门文章
2020软件工程作业05
025 ArrayList 和 LinkedList 的区别是什么?
软件需求分析 要求 模版
没有效率的努力,比懒惰更可怕
为什么你的努力只能坚持几天?
CSS 特性和值
前端需要了解的后端知识
css实用小技巧_css常用技巧和经验总汇
验证码的分类_ 网页验证码有哪些方式?
web游戏框架有哪些?_h5游戏开发引擎推荐
Copyright © 2011-2022 走看看