hasClass for gaining a class?
Hi,
I'm trying to detect whether an element has a class, but I want it to be continually detected. So far I've tried:
- $(document).ready(function() {
- if ($('#myID').hasClass('myClass')) {alert('Now!');}
- });
However, this only checks once - when the page is loaded - which will always return false because the class is only added afterwards. I've also tried taking it out of the document.ready, which doesn't work either.
I feel like the hasClass function should allow for followup, so it would look like:
- $(ele).hasClass('class', function() { do something });
But it doesn't. :(
Thanks for any suggestions,
thugsb