How to make accordion sections both selectors and hyperlinks?

蓝咒 提交于 2019-12-12 07:03:16

问题


I want to make so that accordion titles work both as selectors and as hyperlinks. How is it possible? For example, is is possible to make one part of title to work as section opener and another one as hyperlink?

Just inserting my links does not work:

<div id="accordion">
    <h3><a href="/myhtml1.html">First header</a></h3>
    <div>First content</div>
    <h3><a href="/myhtml2.html">Second header</a></h3>
    <div>Second content</div>
</div>

回答1:


If your using html 5 it is now valid to wrap whole section in anchor tags so you could in theory do something like

<div id="accordion">
    <a href="#">
       <h3>First header</h3>
       <a href="/myhtml1.html">Header link</a>
    </a>
    <div>First content</div>
    <a href="#">
       <h3>Second header</h3>
       <a href="/myhtml2.html">Header link</a>
    </a>
    <div>Second content</div>
   </div>

Then you just have to style your h3 and header link tags with floats etc... Hope that helps.

You can also create a jsFiddle and I can get it working if you like



来源:https://stackoverflow.com/questions/11557955/how-to-make-accordion-sections-both-selectors-and-hyperlinks

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