Hi this is my html structure.
<div class="test-class" style="background-color: red;" >1</div>
<div class="test-class" style="background-color: blue;" >1</div>
<div class="test-class" style="background-color: green;" >1</div>
Here on first page load the background-color of test-class come randomly .
i want to run an function when the background color of test-class is changed . How to do this ?
Edit
so from Is it possible to listen to a "style change" event? this question i got a solution
(function() {
var ev = new $.Event('style'),
orig = $.fn.css;
$.fn.css = function() {
$(this).trigger(ev);
return orig.apply(this, arguments);
}
})();
$('.test-class').bind('style', function(e) {
console.log( $(this).attr('style') );
});
But please help to apply this answer . i want to alert the content of that div and it's color when it's background-color is changed .