tags:

views:

1351

answers:

3

Hi, is it possible to shake a table row if mouse over? and if so how? =)

I have done it before when calling a div, but I havent as yet use the mouse over function, any help appreciated

Thanks =)

+1  A: 

You could try:

$(function(){
   $(".myClass").hover(function() {
         $(this).effect("shake", { times:3 }, 100);
   });
});

Edit: And if I was you I'd try to avoid applying fancy animations to table elements... this might behave dodgy on IE6 particularly, try to do it using divs. Besides why the heck would you want to shake a row? ;-)

rochal
Since you don't need a mouseleave handler, you might as well call `mouseenter` instead of `hover`.
SLaks
shake is a finite animation, so once 'hovered' it will play just once. But agree - you could do it using mouseover function as well.
rochal
Thanks but it "kinda" makes the table a whole mess lol, well its for my nav bar, I dont like usings lists :p
Elliott
edit: seems to work good in IE
Elliott
A: 

Wohoo! Here ya go:

$("div").mouseover(function () {
      $(this).effect("shake", { times:3 }, 300);
});

Straight from the docs for the UI plugin:

http://docs.jquery.com/UI/Effects/Shake

btelles
A: 

I tried some of the answers - you need jQuery and jQuery UI to use effect. With a div it worked. With a row in a table there are some weird non-shake behaviors. With a single TD it did something else weird. You can shake the contents of a TD by placing it in a span. I have included that code below:

<html>
<script type="text/javascript" src="jquery-1.3.2.js" ></script>
<script type="text/javascript" src="jquery-ui-1.7.2.custom.js" ></script>
<body>
<center>
<table border=1>
    <tr><td> a </td> <td> b </td> </tr>
    <tr><td> a1 </td> <td> b </td> </tr>
    <tr><td><span class=myClass> a2 </span></td> <td> b </td> </tr>
    <tr><td> a3 </td> <td> b </td> </tr>
</table>
</center>
<script>

$(function(){
   $(".myClass").hover(function() {
         $(this).effect("shake", { times:3 }, 100);
   });
});

</script>
</body>
</html>

I would take my experiments to mean that you can not shake a row.

Philip Schlump
Thanks for that, it seems to work fine in IE but not firefox, which is strange its usually the other way around
Elliott