问题描述
- bootstrap-hover-dropdown.js
-
使用bootstrap框架,想把下拉菜单弄成渐显渐隐 要怎么改呢 ?(function($, window, undefined) { var $allDropdowns = $(); $.fn.dropdownHover = function(options) { $allDropdowns = $allDropdowns.add(this.parent()); return this.each(function() { var $this = $(this).parent(), defaults = { delay: 300, instantlyCloseOthers: true }, data = { delay: $(this).data('delay'), instantlyCloseOthers: $(this).data('close-others') }, options = $.extend(true, {}, defaults, options, data), timeout; $this.hover(function() { if(options.instantlyCloseOthers === true) $allDropdowns.removeClass('open'); window.clearTimeout(timeout); $(this).addClass('open'); }, function() { timeout = window.setTimeout(function() { $this.removeClass('open'); }, options.delay); }); }); }; $('[data-hover="dropdown"]').dropdownHover(); })(jQuery, this);
时间: 2024-09-21 09:25:10