html5 - How to make <div> active on page load using jQuery -
on page load, want show #tab-2 active , show content under tab-2. how use jquery that. tried $('div > ul > li > a, #tabs-2').show(); did not work.
<div id="tabs"> <ul> <li><a href="#tabs-1"></a></li> <li><a href="#tabs-2"></a></li> <li><a href="#tabs-3"></a></li> <li><a href="#tabs-4"></a></li> </ul> <div id="tabs-1"> "short" content </div> <div id="tabs-2"> "long" content </div> <div id="tabs-3"> "long" content </div> <div id="tabs-4"> "long" content </div> link demo - show tab 2 active onload how looks
thanks @jack quick , correct response
the demo shows using jquery ui's tabs.
when initialize tabs, can specify tab active default, so:
$( "#tabs" ).tabs({ active: 1 }); 1 second tab because tab indices start 0.
for work, need remove $('#tabs-2, a[href="#tabs-2"]').show(); code.
Comments
Post a Comment