Note that there are some explanatory texts on larger screens.

plurals
  1. POCatching Line Breaks in Text
    primarykey
    data
    text
    <p>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 <code>BR</code> tags. Here's my code;</p> <pre><code>&lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; window.onload = function onLoad() { alert("Start"); var intros = this.document.getElementById('EventContent'); if (intros) { for (i = 0; i &lt; intros.length; i++) { var els = intros[i].childNodes; if (els) { for (j = 0; j &lt; els.length; j++) { alert(els[j].tagName) } } } } alert("Start"); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div id="EventContent"&gt; &lt;br /&gt; &lt;br /&gt; 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. &lt;br /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>But my alert Tagname never displays although I do get alerted <code>START</code> and <code>END</code>. What am I doing wrong? How can I catch those stupid lineBreaks...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload