How can I pass a previously captured variable into a background property using jQuery? I'm working with a very large table, a lot of cells and a lot of data. There are multiple colors being used, being applied to the table rather than the cell (with good reason).
Here is my code (greatly condensed HTML)
<table>
<tr>
<td class="nonLevel"><ul class="list"><li>text to go here</li></ul></td>
<td class="block"><a href="#"><ul class="list"><li>text to go here</li></ul></a></td>
<td class="block"><a href="#"><ul class="list"><li>text to go here</li></ul></td>
<td class="block"><a href="#"><ul class="list"><li>text to go here</li></ul></a></td>
<td class="block"><a href="#"><ul class="list"><li>text to go here</li></ul></a></td>
<td class="block"><a href="#"><ul class="list"><li>text to go here</li></ul></a></td>
</tr>
</table>
$(".block").hover(function () {
var myColor = $(this).css("background-color");
$(this).css({'background-color' : 'yellow'});
}, function () {
var cssObj = {
'background-color' : myColor,
}
$(this).css(cssObj);
});
So I'm trying to capture the original color on rollover (which works when I pass the myColor variable into an alert), then change the color to yellow and then on rollout switch back to 'myColor'.
I've looked at addClasss and removeClass, but they don't seem to cut it in terms of how this is set up. Again, the background color is set in CSS on the table, not the cell, this can't be changed.
var cssObj = { 'background-color' : myColor, }cssObjwill crash IE.