问题
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