メニューリンクをクリックしてもコードが実行されないため、コードに問題があるようです。私が作成しているのは基本的に、隣接するボックスの内容を動的に変更するメニューであり、クリックされたメニュー リンクに応じてメニュー リンクの外観を変更します。ここに私のコードの簡略版があります:
HTML:
<td class="instructioncells" colspan="1" width="25%">
<a href="#" onclick="helpmenu(showid)" class="link" id="dashboardlink" style="color:
black; text-decoration: none;">The My Marketing Dashboard</a>
<div style="height:4px;"> </div>
<a href="#" onclick="helpmenu(showid)" class="link" id="methodlink">Selecting a
Method</a>
</td>
<td width="75%" style="vertical-align: top;">
<div id="mymarketingdashboard" style="display: block;">
<div class="font4" style="text-align: center">
The My Marketing Dashboard
</div>
</div>
<div id="selectmethod" style="display: none;">
<div class="font4" style="text-align: center">
Selecting a Method
</div>
</div>
</td>
Javascript:
function helpmenu(showid)
{
var showdashboard = document.getElementById("mymarketingdashboard");
var showmethod = document.getElementById("selectmethod");
var mymarketing = document.getElementById("dashboardlink");
var method = document.getElementById("methodlink");
if (showid == "dashboardlink")
{
showdashboard.style.display = "block";
mymarketing.style.color = "black";
mymarketing.style.textDecoration = "none";
showmethod.style.display = "none";
method.style.color = "#2C3A7F";
method.style.textDecoration = "underline";
}
if (showid == "methodlink")
{
showdashboard.style.display = "none";
mymarketing.style.color = "#2C3A7F";
mymarketing.style.textDecoration = "underline";
showmethod.style.display = "block";
method.style.color = "black";
method.style.textDecoration = "none";
}
コードがそのまま実行されない理由を見つけるための助けは素晴らしいでしょう。よろしくお願いします。