使用jQuery選擇HTML注釋有沒有人知道如何用jQuery選擇HTML注釋節點?<html><head>
<title>Check Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("body *").each(function() {
alert($(this).wrap("<span />").parent().html());
});
});
</script></head><body>
<!-- Hello -->
<p>
<label for="thing">Thing Label</label>
<input id="thing" type="checkbox" />
</p>這不會發表評論。
3 回答

隔江千里
TA貢獻1906條經驗 獲得超10個贊
這似乎與你正在尋找的東西相當:
$(function() { $("body").contents().filter(function(){ return this.nodeType == 8; }).each(function(i, e){ alert(e.nodeValue); }); });
- 3 回答
- 0 關注
- 713 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消