JavaScript運行時錯誤:'console'在Internet Explorer 8中未定義?JavaScript運行時錯誤:'console'在Internet Explorer 8中未定義?
Login form window.onload = function() {
//Select the edit visitors Tab
var siblings = ($("li.pull-right").siblings());
for (var i = 0; i <= siblings.length - 1; i++) {
console.log(siblings[i].innerText.trim().toLowerCase());
if (siblings[i].innerText.trim().toLowerCase() == "edit visitors") {
siblings[i].setAttribute("class", "active pull-right");
} else {
siblings[i].setAttribute("class", "pull-right");
}
}
</script>
</head>
<body>
<div>
<ul class="nav nav-tabs nav-core nav-heros">
<li class="pull-right"><a href="EditVisitor.aspx">Edit Visitors</a></li>
<li class="pull-right"><a href="EditNews.aspx">Edit News</a></li>
<li class="pull-right"><a href="SelectTemplate.aspx">Select Template</a></li>
<li class="pull-right"><a href="Settings.aspx">Settings</a></li>
<li class="active pull-right"><a href="Home.aspx">Home</a></li>
</ul>
</div>
</body>
</html>
粘貼http://jsfiddle.net/ –
代碼移除'console.log(siblings [i] .innerText.trim()。toLowerCase());'因爲IE不支持它。 –