how to hide secondary divs on page load in jquery -


here fiddle:http://jsfiddle.net/timlcooley/lrqt7/3/

i got code what want do, on page load can't figure out how hide second , third div in sequence. works fine when push click buttons, on page load broken. jquery

var $items = $('#vtab>ul>li')`;  $items.click(function () {     $items.removeclass('selected');     $(this).addclass('selected');      var index = $items.index($(this));     $('#vtab>div').hide().eq(index).show(); }).eq(index_obtained_from_the_querystring).click(); 

html

<div id="vtab">     <ul>         <li class="basics selected"><a href="#">basics</a>         </li>         <li class="advanced"><a href="#">advanced</a>         </li>         <li class="combos"><a href="#">combos</a>         </li>     </ul>     <div>          <h3>welcome home!</h3>           <h3>welcome home!</h3>           <h3>welcome home!</h3>           <h3>welcome home!</h3>      </div>     <div>          <h3>secure login</h3>           <h3>secure login</h3>           <h3>secure login</h3>           <h3>secure login</h3>      </div>     <div>          <h3>online support</h3>           <h3>online support</h3>           <h3>online support</h3>           <h3>online support</h3>      </div> </div> 

css give css is functional , long

#vtab > ul > li {     width: 25%;     background-color: #fff !important;     list-style-type: none;     display: block;     text-align: center;     border: 1px solid #000;     position: relative;     opacity: .3;     -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=30)";     filter: progid:dximagetransform.microsoft.alpha(opacity=30);     float:left;     border-radius:10px 10px 0 0;     padding:5px;     border-bottom:none;     margin:2px 8px 10px; } #vtab > ul > li > {     text-decoration:none;     text-shadow:#333333 0 -1px 0;     color:#fff;     font-size:30px;     font-weight:bold; } #vtab > ul > li.basics {     background: #4f914e;     /* old browsers */     background: -moz-linear-gradient(left, #4f914e 0%, #63aa63 30%, #63aa63 70%, #4f914e 100%);     /* ff3.6+ */     background: -webkit-gradient(linear, left top, right top, color-stop(0%, #4f914e), color-stop(30%, #63aa63), color-stop(70%, #63aa63), color-stop(100%, #4f914e));     /* chrome,safari4+ */     background: -webkit-linear-gradient(left, #4f914e 0%, #63aa63 30%, #63aa63 70%, #4f914e 100%);     /* chrome10+,safari5.1+ */     background: -o-linear-gradient(left, #4f914e 0%, #63aa63 30%, #63aa63 70%, #4f914e 100%);     /* opera 11.10+ */     background: -ms-linear-gradient(left, #4f914e 0%, #63aa63 30%, #63aa63 70%, #4f914e 100%);     /* ie10+ */     background: linear-gradient(to right, #4f914e 0%, #63aa63 30%, #63aa63 70%, #4f914e 100%);     /* w3c */     filter: progid:dximagetransform.microsoft.gradient(startcolorstr='#4f914e', endcolorstr='#4f914e', gradienttype=1);     /* ie6-9 */ } #vtab > ul > li.advanced {     background: #dd412c;     /* old browsers */     background: -moz-linear-gradient(left, #dd412c 0%, #f2552e 30%, #f2552e 70%, #dd412c 100%);     /* ff3.6+ */     background: -webkit-gradient(linear, left top, right top, color-stop(0%, #dd412c), color-stop(30%, #f2552e), color-stop(70%, #f2552e), color-stop(100%, #dd412c));     /* chrome,safari4+ */     background: -webkit-linear-gradient(left, #dd412c 0%, #f2552e 30%, #f2552e 70%, #dd412c 100%);     /* chrome10+,safari5.1+ */     background: -o-linear-gradient(left, #dd412c 0%, #f2552e 30%, #f2552e 70%, #dd412c 100%);     /* opera 11.10+ */     background: -ms-linear-gradient(left, #dd412c 0%, #f2552e 30%, #f2552e 70%, #dd412c 100%);     /* ie10+ */     background: linear-gradient(to right, #dd412c 0%, #f2552e 30%, #f2552e 70%, #dd412c 100%);     /* w3c */     filter: progid:dximagetransform.microsoft.gradient(startcolorstr='#dd412c', endcolorstr='#dd412c', gradienttype=1);     /* ie6-9 */ } #vtab > ul > li.combos {     background: #2f32ed;     /* old browsers */     background: -moz-linear-gradient(left, #2f32ed 1%, #2ea7e8 30%, #2ea7e8 70%, #2f32ed 100%);     /* ff3.6+ */     background: -webkit-gradient(linear, left top, right top, color-stop(1%, #2f32ed), color-stop(30%, #2ea7e8), color-stop(70%, #2ea7e8), color-stop(100%, #2f32ed));     /* chrome,safari4+ */     background: -webkit-linear-gradient(left, #2f32ed 1%, #2ea7e8 30%, #2ea7e8 70%, #2f32ed 100%);     /* chrome10+,safari5.1+ */     background: -o-linear-gradient(left, #2f32ed 1%, #2ea7e8 30%, #2ea7e8 70%, #2f32ed 100%);     /* opera 11.10+ */     background: -ms-linear-gradient(left, #2f32ed 1%, #2ea7e8 30%, #2ea7e8 70%, #2f32ed 100%);     /* ie10+ */     background: linear-gradient(to right, #2f32ed 1%, #2ea7e8 30%, #2ea7e8 70%, #2f32ed 100%);     /* w3c */     filter: progid:dximagetransform.microsoft.gradient(startcolorstr='#2f32ed', endcolorstr='#2f32ed', gradienttype=1);     /* ie6-9 */ } #vtab > ul > li.selected {     opacity: 1;     -ms-filter:"progid:dximagetransform.microsoft.alpha(opacity=100)";     filter: progid:dximagetransform.microsoft.alpha(opacity=100);     border: 1px solid #ddd;     border-bottom: none;     z-index: 10;     background-color: #fafafa !important;     position: relative; }  #vtab > div {     clear:both;     overflow:hidden; }  #vtab div > h3{     background: #990099; /* old browsers */ background: -moz-linear-gradient(left,  #990099 0%, #d300d0 30%, #d300d0 70%, #990099 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, right top, color-stop(0%,#990099), color-stop(30%,#d300d0), color-stop(70%,#d300d0), color-stop(100%,#990099)); /* chrome,safari4+ */ background: -webkit-linear-gradient(left,  #990099 0%,#d300d0 30%,#d300d0 70%,#990099 100%); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(left,  #990099 0%,#d300d0 30%,#d300d0 70%,#990099 100%); /* opera 11.10+ */ background: -ms-linear-gradient(left,  #990099 0%,#d300d0 30%,#d300d0 70%,#990099 100%); /* ie10+ */ background: linear-gradient(to right,  #990099 0%,#d300d0 30%,#d300d0 70%,#990099 100%); /* w3c */ filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#990099', endcolorstr='#990099',gradienttype=1 ); /* ie6-9 */     border-radius:5px;     margin:2px 0;     font-size:22px;   font-weight:bold;   list-style:none;   margin:2px 8px;   text-align:center;   text-shadow:#333333 0 -1px 0;   color:#fff;   padding:5px;   width:220px;     } 

thanks help.

do

var $items = $('#vtab>ul>li');  $items.click(function () {     $items.removeclass('selected');     $(this).addclass('selected');      var index = $items.index($(this));     $('#vtab>div').hide().eq(index).show(); }).eq(0).click(); 

demo: fiddle

if want able set of 3 items default 1 then

var $items = $('#vtab>ul>li');  $items.click(function () {     $items.removeclass('selected');     $(this).addclass('selected');      var index = $items.index($(this));     $('#vtab>div').hide().eq(index).show(); }).filter('.selected').click() 

demo: fiddle


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -