索引.html
<!DOCTYPE html>
<html>
<head>
<script>
function cha(title){
document.getElementById("change").innerHTML=title;
}
</script>
</head>
<body>
<ul> //sample navigation bar
<li><a href='index.html'>Home</a></li> //sample navigation bar
<li><a href='mission.html' onclick='cha("Mission")'>Mission</a></li> //sample navigation bar
</ul> //sample navigation bar
THIS IS MY HOME PAGE
</body>
</html>
任务.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ul> //sample navigation bar
<li><a href='index.html'>Home</a></li> //sample navigation bar
<li><a href='mission.html'>Mission</a></li> //sample navigation bar
</ul> //sample navigation bar
<h1 id='change'>THIS IS MY Mission </h1>
</body>
</html>
这 2 个网页的理想输出是当我单击 index.html 中的任务时,mission.html 中的标题<h1>
将更改其内部内容,从 THIS IS MY Mission 它将变成仅如中所述的任务cha("Mission");
,但我不知道这是错误的在我的代码中,我的理想输出没有显示。谢谢大家,对我的语法感到抱歉。