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无效,似乎只是破坏了脚本。我错过了什么吗?
答案 0 :(得分:3)
检查你的拼写
var linkElementLnk = document.getElementById("BackButtonlnk");
...
linkElementLink.style.display = 'none';
答案 1 :(得分:0)
尝试
style.display = '';