首页 > 解决方案 > 使用 jQuery 在悬停时摇动

问题描述

我正在尝试在 jQuery 中制作一个框架按钮悬停效果。请帮助我想在悬停时摇动锚标签

它看起来像这样:

$(document).ready(function() {
  $(".neon").hover(function() {
    $(this).toggle().effect("shake")
  })
})

标签: jquery

解决方案


这可以解决问题。

$("#toggle").hover(function() {
  $( "#toggle" ).effect( "shake", {times:2}, 1000  );
});
<!doctype html>
<html lang="en">
<head>
  <script src="//code.jquery.com/jquery-1.12.4.js"></script>
  <script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
 
<p>Click anywhere to shake the box.</p>
<div >
  <a href="" id="toggle">Try</a>
</div>
 


推荐阅读