addClass / removeClass Bug?
So here's what Im trying to do:
I have a table with over 100 rows, and I am using mouseOver to change the class to 'highlight' the row. I am trying to add some jQuery to make the highlight effect a little more aesthetically pleasing.
Here's the logic:
on <tr> mouse over
change class to 'highlight'
on <tr> mouse out
change class back to original with a slight fade
Here's some samples:
Youtube video of the issue
Link to working Demo
Here's the code:
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
- <style>
- .color0
- {border:none; background:#999999;}
- .color1
- {border:none; background:#bbbbbb;}
- .highlight
- {background:#A0D0F0;}
- </style>
- <script type="text/javascript">
- $(document).ready(function() {
- $("tr").mouseout(function () {
- $(this).removeClass("highlight", 400);
- });
- $("tr").mouseenter(function () {
- $(this).addClass("highlight", 40);
- });
- });
- </script>
- <tr align='center' class='color0'></tr>
- <tr align='center' class='color1'></tr>
It seems like the method I am using is not efficient enough to keep up with quick mouse movements.
Is there a better way to do this?
Any help would be greatly appreciated.