JQuery script operator == doesn't work on website, but works on local

After testing my code on a local server and observing that it works fine, I implemented it on my website, but it does not work. If I change if (count == 3) { to if (count == 3) { , it works, but then I get a loop on BANNER that I'm trying to implement. So why does one work and the other not? Both methods work in the local host.

it is configured here: http://lucrebem.com.br/blog/emponline/90-o-hotmart-ea-pirataria-uma-tragica-estoria-de-amor-em-3-atos

 jQuery(function($) { var newHtml = ''; var count = -1; function check() { if (count == 3) { newHtml += 'MY BANNER HTML GOES HERE' //count == 1 } } $(".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; }) } }); check(); $(".newsitem_text").html(newHtml); }); 
0
source share

Source: https://habr.com/ru/post/1235439/


All Articles