jquery - If category is 'x' add class -


morning all,

just quick question, within loop check if element has category 'nolink' if add class.

...

my code below. jquery remove class client-hover if a attribute #. doesn't appear work.

many thanks

<?php  query_posts( 'category_name=projects' ); while ( have_posts() ) : the_post();         $href = ( has_term( 'nolink', 'category' ) ) ? '#' : get_permalink();         echo '<div class="grid_3">';         echo '<a href="' . $href . '">';             echo '<ul class="work-thumb-wrap client-hover post_class();">';                 echo '<li class="work-popup">';                     echo '<p>';                         echo 'view client work';                     echo '</p>';                 echo '</li>';                 echo '<li class="work-img">';                     echo '<img src="';                         echo the_field('client_thumb');                     echo '">';                 echo '</li>';             echo '</ul>';         echo '</div>'; endwhile; wp_reset_query(); ?>  <script type="text/javascript">     if($('href').attr('#') === null) {          $('.work-thumb-wrap').removeclass('client-hover');     }      $('.work-thumb-wrap').mouseenter(function(){         $(this).children('.work-popup').animate({'bottom' : '0px'}, 200);     });      $('.work-thumb-wrap').mouseleave(function(){         $(this).children('.work-popup').animate({'bottom' : '-40px'}, 200);     }); </script> 

your first javascript if wrong. should this:

imperatively:

$('a').each(function () {     if ($(this).attr('href') == '#') {         $(this).find('.work-thumb-wrap').removeclass('client-hover');     } }); 

or simply:

$('a[href="#"] .work-thumb-wrap').removeclass('client-hover'); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -