点击改变p和div元素:
<!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>test javascript</title>
<style type="text/css">
body{
margin:0px;
padding:0px;
background:#999999;
}
#button{
border-radius:6px;
color:#00FF00;
font-size:16px;
}
</style>
</head> <body>
<h1>My Site</h1>
<p id="demo">一个段落</p>
<div id="myDIV" onclick="JavaScript:alert("hello lt")">一个div块</div>
<button type="button" id="button" onclick="myFunction()" >click me</button>
<script type="text/javascript">
function myFunction(){
document.getElementById("demo").innerHTML="Hello world!";
document.getElementById("myDIV").innerHTML = "How are you!";
}
</script>
</body>
</html>