很多时候我们只知道一些函数的定义,但就是不知道它们的用法 ,给自己留个笔记,以后看
看代码:
<!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>
<form action="" method="post">
<h1 id="xinlang">新浪
<input type="button" onclick="myFunction()" value="改变框里面的内容"/></h1></form>
<script type="text/javascript">
function myFunction(){
x=document.getElementById("xinlang");
x.innerHTML="淘宝";
}
</script>
</body>
</html>
函数运行结果:
点击按钮之后结果变成下面的情况: