手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >javascript实现随机读取数组的方法
javascript实现随机读取数组的方法
摘要:本文实例讲述了javascript实现随机读取数组的方法。分享给大家供大家参考。具体如下:functionwrite_quote(){var...

本文实例讲述了javascript实现随机读取数组的方法。分享给大家供大家参考。具体如下:

function write_quote() { var quotes = [ 'no animals were harmed while making this page', 'made in ulm', 'this page was handmade', 'Get <a href="http://www.mozilla.org/products/firefox/">FireFox</a> :-)' ]; var r = Math.round(Math.random() * (quotes.length-1)); // write the quote document.write(quotes[r]); // or replace an HTML element: // document.getElementById("quote").innerHTML = quotes[r]; }

希望本文所述对大家的javascript程序设计有所帮助。

【javascript实现随机读取数组的方法】相关文章:

javascript实现炫酷的拖动分页

javascript中this的四种用法

理解javascript定时器中的单线程

JavaScript中Number.MAX_VALUE属性的使用方法

Javascript随机显示图片的源代码

理解javascript封装

JavaScript数据结构与算法之栈与队列

JavaScript基本语法讲解

JavaScript动态添加style节点的方法

JavaScript中的parse()方法使用简介

精品推荐
分类导航