Why the onclick event is triggered after the page is loaded by itself, without pressing?

0 like 0 dislike
Help to understand, have a day without sleep will soon go crazy.
There is a script that hides part of the number

jQuery(document).ready(function($){ $.fn.textToggle = function(cls, str) { return this.each(function(i) { $(this).click(function() { var c = 0, el = $(cls).eq(i), arr = [str,el.text()]; return function() { el.text(arr[c++ % arr.length]); }}()); })}; $(function(){ $('.nomer_shapka').textToggle(".nomer_shapka",").click(); $('.nomer_shapka').textToggle(".num_hide","XX-XX").click(); }); });

A to it HTML code

The essence of simple code - hiding the last 4 digits of the phone number instead - XX-XX. Clicking on the SHOW button, they appear and the show button disappears. + The goal is sent to Google.

If this objective with the onclick event to hang on any other element of the website all OK, activated at the touch, but in this code the purpose of is triggered itself immediately after page load.

Tell me where I went wrong or what to add to make it work correctly.
by | 3 views

1 Answer

0 like 0 dislike
Your code clicks:


Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
33,945 users