opacity
is not a property of jQuery object.
One possible solution is to test whether the td has the tdClicked
class instead of testing for opacity value
$('td').mouseenter(function () {
$(this).fadeTo('fast', 0.99);
});
$('td').mouseleave(function () {
if (!$(this).hasClass('tdClicked')) {
$(this).fadeTo('fast', 0.8);
}
});
$('td').click(function () {
$(this).toggleClass('tdClicked');
});
Demo: Fiddle
Using your way: Fiddle