亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

關于dom判斷空白節點

關于dom判斷空白節點

朝花bu夕拾 2016-08-24 22:18:14
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>nextSibling</title></head><body><ul id="u1"> ??? ? ? ? ? ? <li id="a">javascript</li> ??? ? ? ? ? ? <li id="b">jquery</li> ??? ? ? ? ? ? <li id="c">html</li> ??? ? ? ? </ul> ??? ? ? ? <ul id="u2"> ??? ? ? ? ? ? <li id="d">css3</li> ??? ? ? ? ? ? <li id="e">php</li> ??? ? ? ? ? ? <li id="f">java</li> ??? ? ? ? </ul> ??<script type="text/javascript">? ? function get_nextSibling(n){? ? ? ? var x=n.nextSibling;? ? ? ? while (x && x.nodeType!=1){? ? ? ? ? ? x=x.nextSibling;? ? ? ? }? ? ? ? return x;? ? }? ? var x=document.getElementsByTagName("li")[0];? ? document.write(x.nodeName);? ? document.write(" = ");? ? document.write(x.innerHTML);? ??? ? var y=get_nextSibling(x);? ??? ? if(y!=null){? ? ? ? document.write("<br />nextsibling: ");? ? ? ? document.write(y.nodeName);? ? ? ? document.write(" = ");? ? ? ? document.write(y.innerHTML);? ? }else{? ? ? document.write("<br>已經是最后一個節點"); ? ? ?? ? }</script></body></html>問題1:? while 中的(x && x.nodeType!=1) ? 為什么這里要用上x&&x.nodeType!=1;執行順序是啥??瞻坠濣c的type不是3嗎?為什么要用上這么一段判斷語句呢?直接判斷x.previousSibling=3不就行了嗎?為什么要用上x&&x.nodeType!=1呢?求詳細點解答。謝謝了!很迷惑
查看完整描述

2 回答

?
君丿

TA貢獻2條經驗 獲得超0個贊


<script>alert('11') </script>

查看完整回答
反對 回復 2016-08-25
  • 2 回答
  • 0 關注
  • 1944 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號