【发布时间】:2016-09-14 21:59:48
【问题描述】:
- Given:带有导航元素的简单标题。
- 何时:用户将鼠标悬停在标题导航元素上并出现一个迷你浮出控件
- 然后:用户必须单击元素才能显示浮出控件
下面的代码非常适合悬停,但我希望在单击而不是悬停时出现迷你弹出窗口。当我将 .hover 更改为 .click 时,没有任何反应。
有什么想法吗?
jQuery
jQuery(document).ready(function () {
function displayFlyout(main_id, content_id) {
jQuery(main_id).hover(function () {
jQuery(content_id).stop(true, true).slideDown('fast');
jQuery(this).addClass("fly-dropdown");
},
function () {
jQuery(content_id).stop(true, true).slideUp(200);
jQuery(this).removeClass("fly-dropdown");
}
);
}
displayFlyout("#example_one", "#example_one_content");
displayFlyout("#example_two", "#example_two_content");
displayFlyout("#example_three", "#example_three_content");
});
Html(只是浮出控件的一个示例)
<ul class="header_flyout col-md-10 pull-right">
<li class="contact_us">
<div id="example_one" class="no-dropdown">
<span class="menu"><?php echo $this->__('Example'); ?></span>
<div class="header-dropdown-content" id="example_one_content">
<span class="blue-arrow"> </span>
<?php echo $this->getChildHtml('contact_mini'); ?>
</div>
</div>
</li>
<li>.....</li> (example two)
<li>.....</li> (example three)
</ul>
【问题讨论】:
标签: javascript jquery hover click