JS li标签点击不在IE8上工作我正在使用下面的JS,但是李onClick不在IE8浏览器上工作。小提琴链接:http://jsfiddle.net/sudheera/DUZ3B/14/HTML<div class="primaryNav fl"><ul id="hd_vertical" class="productNav"><li id="hd_test" class="flight">
<span class="navIcon flightIcon hd_test">Test</span><a class="hd_test" href="
</li><li id="hd_test1" class="bus"><span class="navIcon busIcon hd_test1">Test</span>
<a class="hd_test1" href="http://www.w3schools.com/">Buses</a></li></ul></div>JSvar changeLocation = function(id) {
var _url = document.getElementsByClassName(id)[1].getAttribute('href');
location.href = _url; }document.getElementById("hd_vertical").addEventListener("click",function(e) {
if(e.target.nodeName == "LI") {
var _anchor = e.target.id;
changeLocation(_anchor);
} else if(e.target.nodeName == "SPAN") {
var span = e.target;
var li = span.parentNode;
var _anchor = li.id;
changeLocation(_anchor);
}});请建议
添加回答
举报
0/150
提交
取消