开发者

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开发者_如何学C

Thanks =)


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜