日期:2014-05-16  浏览次数:20290 次

点击第一次正常第二次确还原了(不正常)第三次正常 什么情况啊(帮帮忙啊大神们)
这是我的代码
JScript code
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;
}


------解决方案--------------------
百度上面的链接地址?

有用JQUERY吗?用那个方便多了
------解决方案--------------------
JScript code
        if (childArray[i] != s && childArray[i].tagName == "A") {

            // return !setu(s);
            childArray[i].onclick = ""; //问题可能出在这一行,执行后解除了原先绑定到所有没有被点击的链接的onclick事件处理函数
           // childArray[i].innerHTML = "haha";
        }