So I'm analysing a bunch of HTML in javascript so that I can trim this article down to 30 characters-ish and append something like '...READ MORE' etc. Problem is that the block of text is spaced out with BR
tags. Here's my code;
<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>
But my alert Tagname never displays although I do get alerted START
and END
. What am I doing wrong? How can I catch those stupid lineBreaks...