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>
运行代码
查看全文
相关阅读:
解说asp.net core MVC 过滤器的执行顺序
asp.net core 2.0 Microsoft.Extensions.Logging 文本文件日志扩展
【技术累积】【点】【java】【30】代理模式
【技术累积】【点】【java】【29】MapUtils
【技术累积】【点】【java】【28】Map遍历
【技术累积】【点】【java】【27】@JSONField
【技术累积】【点】【java】【26】@Value默认值
【技术累积】【点】【java】【25】Orderd
【技术累积】【点】【java】【23】super以及重写重载
【技术累积】【线】【java】【2】AOP
原文地址:https://www.cnblogs.com/jikey/p/1756155.html
最新文章
用debugfs挂载硬盘,删除损坏的文件
数据资源
机器学习资源
docker源码打包RPM
docker二进制代码编译
docker的分层
【tools&tips】sphinx生成本页面的带链接目录
【tools&tips】ifttt-Put the internet to work for you
【tools&tips】使用reStructuredText写博客
【python】pprint格式化输出
热门文章
【python】Google Python 风格指南
猩球StarBall ,一个方便约球的小程序
尝鲜.net core2.1 ——编写一个global tool
使用parcel打造一个零配置的react工作流
更好的小票打印体验,huanent.printer2.0发布
(翻译)使用Api分析器与Windows兼容包来编写智能的跨平台.NET Core应用
使用Microsoft.AspNetCore.TestHost进行完整的功能测试
Dapper.Contrib——更加优雅地使用Dapper进行增删改查
asp.net core webapi 服务端配置跨域
在IIS使用localDB
Copyright © 2011-2022 走看看