Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee 朱秋贵内科诊所 My腾云code

firefox与IE的nextSibling

提取dom邻节点(兄弟节点)

<h2  onclick="show(this)">

  <ul>

  <li></li>

  <li></li>  

  </ul>

</h2>

function show(ob) {
    var index= ob.nextSibling.nodeType;
    var reObj;
    if (index== 3) {    //firefox
        reObj= ob.nextSibling.nextSibling;
    }
    else {     //IE
        reObj= ob.nextSibling;
    }
    if (reObj.style.display == '' || reObj.style.display != 'none')
        reObj.style.display = 'none';
    else
        reObj.style.display = '';
}

posted @ 2010-01-26 16:57  cn2024  阅读(226)  评论(0编辑  收藏  举报