日期:2014-05-16 浏览次数:20290 次
function setu(s) { // var thisObject = evt.srcElement || evt.target; var thisObjectParent = s.parentNode; var childArray = thisObjectParent.childNodes; var text = s.innerHTML; var newchild = document.createElement("strong"); thisObjectParent.replaceChild(newchild, s); newchild.innerHTML = text; return false; } function changenav(s) { var thisObjectParent = s.parentNode; var childArray = thisObjectParent.childNodes; //alert(childArray[0].tagName + "," + childArray[1].tagName + "," + childArray[2] + "," + childArray[3] + "," + childArray[4]); // alert(s.innerHTML); var anewchild = document.createElement("A"); for (var i = 0; i < childArray.length; i++) { if (childArray[i] != s && childArray[i].tagName == "A") { // return !setu(s); childArray[i].onclick = ""; // childArray[i].innerHTML = "haha"; } if (childArray[i] == s) { setu(s); //alert(s.tagName) } // alert(childArray[i] != s); } return false; }
if (childArray[i] != s && childArray[i].tagName == "A") { // return !setu(s); childArray[i].onclick = ""; //问题可能出在这一行,执行后解除了原先绑定到所有没有被点击的链接的onclick事件处理函数 // childArray[i].innerHTML = "haha"; }