I have some functions that start when an element is clicked. Elements are stored in an array. But the value that calls the function changes. Here is the code for the function:
// first I store the element of a list in an array var promo = new Array(), indexOfTheElement = 3; $('#list li').each(function(){ promo.push($(this)); }); $(myArray[indexOfTheElement]).click(function(){ indexOfTheElement--; // Do something return false; });
Edit: The list item is stored in an array, and the function runs when the list item is clicked. For example, if you click on the third element, the function will be launched, and then it will work when you click on the second.
source share