-1

I am just trying to alert a message when a class is added to a div. The class is added after the document ready so I figured I would have to use the LIVE function ?

Am I right so far ?

This is what I am trying to implement but I have no luck.

I have done a click function test just to verify that the classes are actually right and they are.

if ( $(".profile-tabs .favourite").live("hasClass","active") ) { alert('test'); };

Can someone give me a hand ? Thanks

Kiwimoisi
  • 4,086
  • 6
  • 33
  • 64
  • possible duplicate of [jQuery - Fire event if CSS class changed](http://stackoverflow.com/questions/1950038/jquery-fire-event-if-css-class-changed) – dsgriffin Mar 11 '14 at 03:31

1 Answers1

1

You can fire the event using jquery trigger and same event you can bind with div.

$("button").click(function(){
  $("#mydiv").addClass("Divcss").trigger('cssChange')
});

$("#mydiv").bind('cssChange', function(){ alert('test'); });

JSFiddle Demo

Akhlesh
  • 2,389
  • 1
  • 16
  • 23