2012-07-20 101 views
-9

是否有可能让手风琴在点击时悬停?以及如何做点击其他事情?如何让手风琴扩展在悬停而不是点击?

UPDATE

我说的是jQuery UI的手风琴部件。

+0

当然。现在你试过了什么? – j08691 2012-07-20 17:30:07

+0

您是否阅读过文档? – Joseph 2012-07-20 17:30:35

+0

我试图以另一种方式询问本网站,并被告知只有在HTML5中才有可能:http://stackoverflow.com/questions/11557955/how-to-make-accordion-sections-both-selectors-and-hyperlinks/ 11558085#11558085我终于达到这样一个明显的问题版本,你开始把坏事给我。感谢你们! – 2012-07-20 17:33:13

回答

1

简单的CSS手风琴:http://jsbin.com/atamat/edit#html,live

.accordion > div { 
    display:none; 
    } 
    .accordion:hover > div { 
    display:block; 
    } 

HTML:

<div class="accordion"> 
    <h2><a href="#link2">Header goes here</a></h2> 
    <div> 
     Content goes here 
    </div> 
    </div> 

    <div class="accordion"> 
    <h2><a href="#link2">Header goes here</a></h2> 
    <div> 
     Content goes here<br />Content goes here<br />Content goes here<br /> 
     Content goes here<br />Content goes here<br />Content goes here<br /> 
     Content goes here<br />Content goes here<br />Content goes here<br /> 
    </div> 
    </div> 

简单的jQuery solutionn:http://jsbin.com/atamat/2/edit#javascript,html,live

$(".accordion > div").hide().parent().hover(function(event) { 
    $(this).children("div").slideToggle(event.type === "mouseenter"); 
}); 

HTML:

同样^