function insert()
{
var linkElement = document.getElementById("BackButton");
var linkElementLnk = document.getElementById("BackButtonlnk");
var loc_array = document.location.href.split('/');
if (loc_array[loc_array.length-3] == "m")
{
linkElementLink.style.display = 'none';
}
else if (loc_array[loc_array.length-2] == "maps"
|| loc_array[loc_array.length-3] == "maps"
|| loc_array[loc_array.length-2] == "stations"
|| loc_array[loc_array.length-3] == "stations" )
{
var newT = document.createTextNode("Stations & Maps");
}
else
{
var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-3])));
}
linkElement.appendChild(newT);
}
这是我的 HTML
<a id="BackButtonlnk" href="#" class="white" onClick="history.go(-1); return false;">
<div id="BackButton1"></div>
<div id="BackButton"></div>
<div id="BackButton3"></div>
</a>
style.display none 不起作用,似乎只是破坏了脚本。我错过了什么吗?
最佳答案
检查拼写
var linkElementLnk = document.getElementById("BackButtonlnk");
...
linkElementLink.style.display = 'none';
关于Javascript 样式显示不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3239654/