How do we assign a class based on what an inline variable's value changes to?
Here is the demonstration which is much easier to understand: http://jsfiddle.net/eYGr5/75/
Basically, another script (I don't want to touch) is assigning an inline style to a div. I want to identify when "IF" this style's value has changed, to apply a class to a certain element.
Here is the minified non-interactive copy of the code:
HTML:
<div class="mm-active">mm-active</div>
<div class="mm-container" style="color:DarkGreen;">mm-container: By hovering here, the jQuery should look up the new inline style (DeepPink) and ONLY because of that inline style, turn mm-active lime green!</div>
CSS:
.activefix {
background:Lime;
}
jQuery:
// This function gets the value of an inline style property, (Source: bit.ly/1er8vJ2):
(function($) {
$.fn.inlineStyle = function (prop) {
return this.prop("style")[$.camelCase(prop)];
};
}(jQuery));
// Now how do we assign a class based on what this inline variable changes to?
if ($(".mm-container").inlineStyle("color") == 'DeepPink') {
$('.mm-active').addClass('activefix'); // This should apply "Lime" to mm-active
}