Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery "keyup" crashing page when checking 'Word Count'
    primarykey
    data
    text
    <p>I have a word counter running on a DIV and after typing in a few words, the page crashes. The browser continues to work (par scrolling) and no errors are showing in Chrome's console. Not sure where I'm going wrong...</p> <p>It all started when I passed "<em>wordCount(q);</em>" in "<em>keyup</em>". I only passed it there as it would split-out "NaN" instead of a number to countdown from.</p> <p>JS:</p> <pre><code>wordCount(); $('#group_3_1').click(function(){ var spliced = 200; wordCount(spliced); }) ; $('#group_3_2').click(function(){ var spliced = 600; wordCount(spliced); }) ; function wordCount(q) { var content_text = $('.message1').text(), char_count = content_text.length; if (char_count != 0) var word_count = q - content_text.replace(/[^\w ]/g, "").split(/\s+/).length; $('.word_count').html(word_count + " words remaining..."); $('.message1').keyup(function() { wordCount(q); }); try { if (new Number( word_count ) &lt; 0) { $(".word_count").attr("id","bad"); } else { $(".word_count").attr("id","good"); } } catch (error) { // } }; </code></pre> <p>HTML:</p> <pre><code>&lt;input type="checkbox" name="entry.3.group" value="1/6" class="size1" id="group_3_1"&gt; &lt;input type="checkbox" name="entry.3.group" value="1/4" class="size1" id="group_3_2"&gt; &lt;div id="entry.8.single" class="message1" style="height: 400px; overflow-y:scroll; overflow-x:hidden;" contenteditable="true"&gt; &lt;/div&gt; &lt;span class="word_count" id="good"&gt;&lt;/span&gt; </code></pre> <p>Thanks in advanced!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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