JavaScript随机变换表格背景
s<!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=gb2312" />
<title>无标题文档</title>
</head>
<body>
<table id="pic" cellpadding="0" cellspacing="0" border="1" width="991" height="439" bordercolor="red">
<tr>
<td>picture chanage!</td>
</tr>
</table>
<Script Language="JavaScript">
window.onload=function()
{
changePicture();
}
function changePicture(){
image = new Array(3); //定义image为图片数量的数组
image [0] = '1.jpg' //背景图象的路径
image [1] = '2.jpg'
image [2] = '3.jpg'
image [3] = '4.jpg'
number = Math.floor(Math.random() * image.length)+1;
document.getElementById('pic').background="images/"+number+".jpg";
}
</Script>
</body>
</html>
相关文档:
要取什么值?
取value:getElementById("STB_433").value;
取状态(是否check):getElementById("STB_433").checked
取ID:getElementById("STB_433").id
...
var checkboxs=document.getElementsByTagName("input");
var i;
for(i=0;i<checkboxs.length;i++)
{
if(checkboxs[i].type=='checkbox')
{ ......
5、用 构造函数+原型 定义一个类;同一构造函数可以定义出多个类型
/**
* $define 写类工具函数之二
* @param {Object} constructor
* @param {Object} prototype
*/
function $define(constructor,prototype) {
var c = constructor || function(){};
var p = prototype || {};
r ......
首先是十个JS FRAMEWORK
jquery
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
jquery UI
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
Chrome Frame
<script src=& ......
最近这段时间一直在搞前端JavaScript,以前总觉得JS没什么搞头,经过这一段的应用,才发现Js里面的东西真的很深很深的,不然为什么各大门户网站都招一批JS工程师呢。
闲话不说,现在看看JavaScript
里的闭包
。
要成为高级 JavaScript 程序员 ......