javascript - How to add class active for first tab in dynamic li -


i want show first tab content after page load. don't know exact how add class active first li , first content . here code.

            <div class="container">            <ul class="nav nav-tabs">           <?php foreach($category->result() $cate){ ?>          <li><a data-toggle="tab"  href="#cat<?php echo $cate->id; ?>"><?php                   echo $cate->category_name; ?></a></li>           <?php } ?>             </ul>        <div class="tab-content">       <?php foreach($category->result() $cat){ ?>         <div id="cat<?php echo $cat->id; ?>" class="tab-pane fade">          <?php $catego = $cat->id;     $servi = $this->db->select('*')->from('sundaland_services')->where('service_category_id',$catego )->get()->result();     ?>   <p>   <?php foreach($servi $ser11){ ?>                   <div class="col-sm-6 col-md-4">                 <div class="hovereffect">                     <img src="<?php echo base_url(); ?>images/services/original/<?php echo $ser11->service_image; ?>" alt="">                     <div class="overlay">                          <a class="btn-thm btn-xs" href="<?php echo base_url();?>services/main_services_detail/<?php echo $ser11->id;?> ">read more <i class="fa fa-arrow-circle-right"></i></a>                      </div>                 </div>                 <div class="clearfix"></div>                 <h4 style="font-size: 16px!important;"><?php echo $ser11->service_title; ?></h4>                     <p class="details"><?php echo word_limiter($ser11->service_description, 15); ?></p>             </div>  <?php  }    ?>     </p>        </div>        <?php } ?>       </div>       </div> 

i want first tab open default after page load. how this? there need add javascript this?

try this:

$('li').first().addclass('active'); 

it add active class first li.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -