-2

I am creating teams rating site. Here i need to use js, but i cant understand, what is wrong.

function teamopen() {
        if ($('.tb-one-middle').eq(event.page.index).hasClass('current')) { 
            $('.tb-one-middle').eq(event.page.index).removeClass('current');
        }   else {
                $('.tb-one-middle').eq(event.page.index).addClass('current');
                    }
    }

this is my script, it is based onclick from element. I will have many copied elements on one page, they have same classes. So, the script need to open the full information about team with photos, when we click on element. Firstly only the first team has class active. But i need to add this class to any other objects without deleting it from already existing elements.

This is the screenshot of my site, on which you can see the block, which has onclick with google chrome console

This is the screenshot of html part of my site.

Thanks for all in advance!

Claies
  • 22,124
  • 4
  • 53
  • 77
  • Add jQuery correctly before all the custom scripts you wrote. – Sajeeb Ahamed Apr 14 '20 at 10:25
  • You have to load jQuery BEFORE you execute any script that uses jQuery functions like the overloades $() function – Aaron Apr 14 '20 at 10:25
  • `$` is not a "standard" JavaScript reference. The `$` is simply referring to a function in this case. That function could be *any* function in your code, but `$` is **very commonly** used to refer to the base functions in the jquery function library; it is so commonly used that people send out code using the jquery library without bothering to tell the consumers that it is needed. see https://learn.jquery.com/about-jquery/how-jquery-works/ for more detail. – Claies Apr 14 '20 at 10:31
  • There is a new problem, firstly thanks for JQuery, i`ve forgot to install it. prnt.sc/rz0p6h –  Live Chanell Apr 14 '20 at 10:40

1 Answers1

0

It seems that you have to make sure that JQuery is loaded before the execution of that script.

  • There is a new problem, firstly thanks for JQuery, i`ve forgot to install it. https://prnt.sc/rz0p6h –  Live Chanell Apr 14 '20 at 10:37
  • @LiveChanell i would look at the piece of code that has the [something].index . You may be trying to do an indexOf on a string or something of the sort. – Taoufik Fekih Apr 15 '20 at 15:51