There are markup elements, for example li tags, which are in rotation and are alternately assigned and removed the class "active". How can I track class changes and if the class has changed, for example, from "active" to "current", call another function? Climb into the script rotator is not possible.
3 answers
If css classes are assigned using the jquery addClass function, then it is enough just to overwrite it, and thus intercept the call:
var origFn = $.fn.addClass; $.fn.addClass = function(className) { // Выполняем здесь необходимый нам код // и вызываем оригинальную функцию origFn.apply(this, arguments); }
- 2but that's not
$.fn.val
but still probably$.fn.addClass
- GLAGOLA - I apologize) I just copied a piece of my code, and I didn’t change it to addClass everywhere - Pavel Azanov
|
Operate in logical expressions with something like this:
$("li").hasClass("current")
Next - a matter of technology ...
|
If there are not very many of them, launch the function when loading the page, which will collect the values of the classes of these elements into an array.
Then, once a second (for example), again loop over the elements and compare with the array, run all we need, the new values - into the array. And in a circle.
- wow, this is an extreme case - makregistr
|