开发者

Javascript style display not working

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);
}

and here is my 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>

The styl开发者_运维知识库e.display none is not working and seems to just be breaking the script. Am I missing something?


check your spelling

var linkElementLnk = document.getElementById("BackButtonlnk");
...
linkElementLink.style.display = 'none';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜