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>
运行代码
查看全文
相关阅读:
Git 远程仓库 git remote
同一台电脑关于多个SSH KEY管理
dotnet core on Linux 环境搭建及入门demo
Cannot load JDBC driver class 'com.mysql.jdbc.Driver '
Mac OS 配置Maven
Linux中profile、bashrc、bash_profile之间的区别和联系
如何在Mac的Finder中显示/usr、/tmp、/var等隐藏目录
Mac OS X 下查看和设置JAVA_HOME
SSM框架整合(IntelliJ IDEA + maven + Spring + SpringMVC + MyBatis)
事件
原文地址:https://www.cnblogs.com/jikey/p/1756155.html
最新文章
微信小程序——使用excel-export导出excel
IDEA操作——导入maven项目
微信小程序——聚合Aggregate操作实例中match()无法按照Date时间查询
微信小程序——引入Vant组件库
Javascript数组——push() 和 concat()
微信小程序ES6——箭头函数中的this问题
微信小程序H5——自定义属性data-*
微信小程序ES6——字符串模板
Oracle函数——MINUS
微信小程序云数据库——where查询和doc查询区别
热门文章
atom 常用插件
常用的js
常用的vue
webpack4.12.0 安装过程中遇到的问题
我们可以利用css3来实现这个小三角
快速本地搭建一个纯静态简易站点
了解真实的 rem 手机屏幕适配
常用网站
ajax创建XMLHttpRequest对象
[转] 在Mac上搭建React Native开发环境
Copyright © 2011-2022 走看看