我需要.slideToggle来处理悬停(jQuery) [英] I need .slideToggle to work on hover (jQuery)

查看:130
本文介绍了我需要.slideToggle来处理悬停(jQuery)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个导航div,点击打开。我的客户希望链接打开div链接到一个页面,而不是切换悬停div(所以链接可以导致点击另一个页面)。

I've got a navigation div that toggles open on click. My client wants the link that opens the div to link to a page, and toggle the div on hover instead (so the link can lead to another page on click).

以下是我目前使用的代码:

Here's the code I've got so far:

<script>
$(document).ready(function(){
   $("#drawer").hide();
   $(".toggle-drawer").show();

   $('.toggle-drawer').click(function(){
      $("#drawer").slideToggle();
   });  
});
</script>

以下是该网站的链接: http://gearthirty.com (点击supersite链接查看我在说什么)。

Here's the link to the site: http://gearthirty.com (click the "supersite" link to see what I'm talking about).

谢谢提前!

推荐答案

<script>
$(function(){ // DOM ready shorthand

  var $drawer = $("#drawer"); // Cache your elements
  var $togg   = $(".toggle-drawer");

  $drawer.hide();
  $togg.show();

  $togg.hover(function(){
     $drawer.stop().slideToggle();
  }); 

});
</script>

这篇关于我需要.slideToggle来处理悬停(jQuery)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆