所以我正在分析一堆 javascript 中的 HTML,以便我可以将这篇文章缩减为 30 个字符,并附加诸如“...阅读更多”之类的内容。问题是文本块被BR
标签隔开。这是我的代码;
<head runat="server">
<title></title>
<script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
window.onload = function onLoad() {
alert("Start");
var intros = this.document.getElementById('EventContent');
if (intros) {
for (i = 0; i < intros.length; i++) {
var els = intros[i].childNodes;
if (els) {
for (j = 0; j < els.length; j++) {
alert(els[j].tagName)
}
}
}
}
alert("Start");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="EventContent">
<br />
<br />
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<br />
</div>
</form>
</body>
但是我的警报标记名从未显示,尽管我确实收到警报START
并且END
. 我究竟做错了什么?我怎样才能抓住那些愚蠢的断线...