javascript - Nestling multiple accordions in jQuery tabs -
i need create page 3 tabs across top, accordion inside each tab, able load first accordion, , others appear unrendered. appreciated. did see accordion should placed before tabs in instance, thats not working me either.
<head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>details</title> <!-- website styles --> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <link href="css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet"> <style type="text/css"> body { background-color: #000000; } </style> </head> <body> <div class="wrapper"> <div class="one_half"> </div> <div class="one_half last"> <!-- accordion --> <h2 class="demoheaders">tabs</h2> <div id="tabs"> <ul> <li><a href="#tabs-1">first</a></li> <li><a href="#tabs-2">second</a></li> <li><a href="#tabs-3">third</a></li> </ul> <div id="tabs-1"><h2 class="demoheaders">accordion</h2> <div id="accordion"> <h3>first</h3> <div>lorem ipsum dolor sit amet. lorem ipsum dolor sit amet. lorem ipsum dolor sit amet.</div> <h3>second</h3> <div>phasellus mattis tincidunt nibh.</div> <h3>third</h3> <div>nam dui erat, auctor a, dignissim quis.</div> </div> </div> <div id="tabs-2"><div id="accordion"> <h3>first</h3> <div>lorem ipsum dolor sit amet. lorem ipsum dolor sit amet. lorem ipsum dolor sit amet.</div> <h3>second</h3> <div>phasellus mattis tincidunt nibh.</div> <h3>third</h3> <div>nam dui erat, auctor a, dignissim quis.</div></div> <div id="tabs-3">nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. mauris porttitor ullamcorper augue.</div> </div> </div> </div> </div> <!-- jquery scripts --> <script src="js/jquery-1.9.1.js"></script> <script src="js/jquery-ui-1.10.3.custom.js"></script> <script>$(function() { $( "#accordion" ).accordion(); $( "#tabs" ).tabs(); }); </script> </body> </html>
you have multiple elements id accordion
, must unique, change them accordion1
, accordion2
, accordion3
then
$( "#accordion1, #accordion2, #accordion3" ).accordion();
or instead of id
use class attribute accordion
then
$('.accordion').accordion();
ex:
<div class="wrapper"> <div class="one_half"> </div> <div class="one_half last"> <!-- accordion --> <h2 class="demoheaders">tabs</h2> <div id="tabs"> <ul> <li><a href="#tabs-1">first</a></li> <li><a href="#tabs-2">second</a></li> <li><a href="#tabs-3">third</a></li> </ul> <div id="tabs-1"><h2 class="demoheaders">accordion</h2> <div class="accordion"> <h3>first</h3> <div>lorem ipsum dolor sit amet. lorem ipsum dolor sit amet. lorem ipsum dolor sit amet.</div> <h3>second</h3> <div>phasellus mattis tincidunt nibh.</div> <h3>third</h3> <div>nam dui erat, auctor a, dignissim quis.</div> </div> </div> <div id="tabs-2"><div class="accordion"> <h3>first</h3> <div>lorem ipsum dolor sit amet. lorem ipsum dolor sit amet. lorem ipsum dolor sit amet.</div> <h3>second</h3> <div>phasellus mattis tincidunt nibh.</div> <h3>third</h3> <div>nam dui erat, auctor a, dignissim quis.</div></div> <div id="tabs-3">nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. mauris porttitor ullamcorper augue.</div> </div> </div> </div> </div>
script
$(function() { $('.accordion').accordion(); $( "#tabs" ).tabs(); });
demo: fiddle
Comments
Post a Comment