How to make accordion partially expand on hover and then fully open on click?

北城以北 提交于 2019-12-13 08:09:29

问题


Is it possible to make accordion partially expand and then fully open on click?

I have been using the following accordion but I am struggling to get this to work. http://jqueryui.com/accordion/

I would like to be able to control the height the accordion opens on hover and then for it to open fully on click.

Thank you in advanced for any help provided.


回答1:


Create the accordion first and then add the hover functionality. below code maybe helpful:

$('.ui-accordion-header').on('mouseenter',function(){

if(!($(this).next('.ui-accordion-content').css('display')=="block"))
{
    $(this).next('.ui-accordion-content').addClass('hover');
}
});

$('.ui-accordion-header').on('mouseleave',function(){
    $(this).next('.ui-accordion-content').removeClass('hover');
});

The .hover class may look something like this:

.hover{display:block !important; height:50px !important;} 


来源:https://stackoverflow.com/questions/31812801/how-to-make-accordion-partially-expand-on-hover-and-then-fully-open-on-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!