通过调用函数改变其内容:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body> <script type="text/javascript">
function changetext(id){
id.innerHTML="Surprise!"
}
</script>
<h1 onclick="changetext(this)">点我啦</h1> </body>
</html>
输出:
点击出现: