I have table which class is forum. My jquery code:
<script type="text/javascript">
$(document).ready(function() {
$('.forum').bind("mouseover", function(){
var color = $(this).css("background-color");
$(this).css("background", "#380606");
$(this).bind("mouseout", function(){
$(this).css("background", color);
})
})
})
</script>
It perfectly works, but is it possible to do it in more efficient way without var color = $(this).css("background-color");. Just after mouseout leave the previous background-color and remove #380606? Thank you.
If you don’t care about IE ≤6, you could use pure CSS …
With jQuery, usually it is better to create a specific class for this style:
and then apply the class on mouseover, and remove it on mouseout.
If you must not modify the class, you could save the original background color in
.data():or