1.定义数组:
var cars = new Array();
cars[0]="Audi";
cars[1]="BMW";
cars[2]="Volvo";
或者:var cars=["Audi","BMW","Volvo"];
2.定义对象:
var person={firstname:"Bill", lastname:"Gates", id:5566};
获取对象:
name=person.lastname;
name=person["lastname"];
3.改变html内容
document.getElementById(id).innerHTML="New text!";
本例改变了 <img> 元素的 src 属性:
<!DOCTYPE html>
<html>
<body>
<img id="image" src="smiley.gif">
<script>
document.getElementById("image").src="landscape.jpg";
</script>
</body>
<
html>
<!DOCTYPE html>
<html>
<body>
<img id="image" src="smiley.gif">
<script>
document.getElementById("image").src="landscape.jpg";
</script>
</body>
<
4.引用jquery
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
</script>