How can I break, stop, each loop when return false is not working?
My code is supposed to place a banner between a content, but it is looping the banner. I need it to display a single banner only. I have tried using `return false;`, like the example fiddle, but it didn't work:
JS FIDDLE:
https://jsfiddle.net/714Lmgfu/3/
The fiddle is an example. This code is running on a web page where the html is generated dynamically, so I need the
.contents() part, can't remove it.
- $(".newsitem_text").contents().each(function () {
-
- if (this.nodeType != 3) {
- newHtml += this.outerHTML;
- count += $(this).text().trim().split(/\s+/).length;
- } else {
- var wordList = $(this).text().trim().split(/\s+/);
-
- $.each(wordList, function (index, word) {
- count++;
- check();
- newHtml += ' ' + word;
- })
- }
-
- return false;
- });