bose
bose

Reputation: 1

Jquery problem inside while loop on wordpress site

jquery not working in after second grid

   <div class="carousel slide carousel1" id="myCarousel1">
      <div class="carousel-inner"><?php 
       $args = array('post_type'=>'post','post_status'=>'publish','orderby'=>'menu_order','order'=>'ASC','posts_per_page'=>'2',
           'tax_query' => array(array('taxonomy' =>'category','field'=>'slug','terms'=>'videos')));
       $team = new WP_Query($args);
       if($team->have_posts()){
           while ( $team->have_posts() ) : $team->the_post();?>
              <div class="item">
                 <div class="panel col-md-4 col-xs-12">                        
                    <div class="panel-header">
                        <h4><?php the_title();?></h4>                                                      
                    </div>  

                 </div>
              </div><?php 
              endwhile;
           }?>                 
       </div>

    </div>

JS

 $(document).ready(function() {

      $( ".panel-header h4" ).click(function() {
            alert('sdfds');
        });
});

Upvotes: 0

Views: 118

Answers (1)

Therichpost
Therichpost

Reputation: 1815

Try this:

jQuery(document).ready(function($) {
  $( ".panel-header h4" ).each(function() {
      $(this).click(function(){
         alert('sdfds');
      });

    });
});

Upvotes: 1

Related Questions