[ js ] 怎麼辨識出HTML中的
我想用 js 辨識 HTML 中的一個文字節點,該節點含有
簡單的例子
<html>
<span id="space">A B</span>
</html>
我試過
javascript:alert('A B'==document.getElementById('space').firstChild.nodeValue)
javascript:
alert('A B'==document.getElementById('space').firstChild.nodeValue)
javascript:alert('A%20B'==document.getElementById('space').firstChild.nodeValue)
javascript:
alert('A\u0020B'==document.getElementById('space').firstChild.nodeValue)
答案都是false,怎樣寫才會是true
環境:Fx3.5、xp sp3
謝謝。
--
補充:如果該節點,沒有
<html>
<span id="space">AB</span>
</html>
javascript:alert('AB'==document.getElementById('space').firstChild.nodeValue)
會是true
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.175.196.140
→
07/15 16:08, , 1F
07/15 16:08, 1F
→
07/15 18:18, , 2F
07/15 18:18, 2F
推
07/15 18:31, , 3F
07/15 18:31, 3F
→
07/15 18:31, , 4F
07/15 18:31, 4F
→
07/15 21:01, , 5F
07/15 21:01, 5F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):