JavaScript / jQuery: change monitor to element?

Is there any way (other than creating a new event) that I can tell when a particular CSS class was added to the element?

+3
source share
3 answers

If you don't have access to the code adding the class, there is a jQuery plugin called livequerythat will allow you to run the code when elements are added to the DOM (or when you do things like adding a class to an element).

http://brandonaaron.net/code/livequery/docs

$('div.myClass').livequery(function() {
     alert('myClass was added');
});

$('#someDiv').addClass("myClass");  // The livequery code will run

This works specifically with jQuery methods.

+4
source

jQuery addClass(), , . , .

, class. . , , .

0

DOM 3 , ... IE onpropertychange (http://msdn.microsoft.com/en-us/library/ms536956(VS.85).aspx).

, . window.setInterval() , .

0

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


All Articles