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>
运行代码
查看全文
相关阅读:
Spring使用c标签时缺失jstl uri="http://java.sun.com/jsp/jstl/core" prefix="c"
Jsp页面报错:The superclass"javax.servlet.http.HttpServlet" was not found on the Java Build Path错误异常
[Spring in action 笔记0]没有xml配置的spring
Java语言和C语言的static的区别以及它们的内存分配方式
为什么连续的scanf会被跳过或不执行
scanf("%[^ ]", str)正则用法,strchr()用法
newInstance参数详解
多线程之BlockingQueue中 take、offer、put、add的一些比较
[Struts2 in action 笔记3]坐享其成的拦截器(栈)
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath
原文地址:https://www.cnblogs.com/jikey/p/1756155.html
最新文章
Dijkstra算法2
Dijkstra算法 1
Bellman-ford算法 无向图
逐梦,无惧
利用Bellman-Ford算法(有向图) 判断负环
Http API触发小程序云函数案例
微信小程序入门笔记-审核上线(5)
微信小程序入门笔记-使用云开发(4)
微信小程序入门笔记-开通云开发(3)
微信小程序入门笔记-小程序创建(2)
热门文章
微信小程序入门笔记-账号注册(1)
js获取当前时间的年月日时分秒以及时间的格式化
Delphi 调用C# 编写的DLL方法
delphi TStringList 用法详解
响应Ajax请求的Json被中的”被转义成"
Maven项目启动报错:Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContex[/XXXXX]
严重: testWhileIdle is true, validationQuery not set 使用Druid连接池报错处理
如何在js校验完成后动态修改 placeholder?
正则表达式“w”无法正常匹配中文
[Mybatis学习] 2.接口代理实现的数据库操作
Copyright © 2011-2022 走看看