Elliott
Elliott

Reputation: 3864

jquery shake on mouse over?

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 =)

Upvotes: 3

Views: 12846

Answers (3)

Philip Schlump
Philip Schlump

Reputation: 3144

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.

Upvotes: 4

btelles
btelles

Reputation: 5420

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

Upvotes: 1

Piotr Rochala
Piotr Rochala

Reputation: 7781

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? ;-)

Upvotes: 2

Related Questions