jquery - Wanting to check for a css class and if it's active change the image src value -
here have far, isn't working right , not sure why. thoughts?
jquery(document).ready(function( $ ) { if ( $('#masthead').hasclass('is-fixed') ) { $('.site-logo-div').attr('src','second.jpg'); } })( jquery );
edits: html
<header id="masthead" class="site-header header-fixed" role="banner" style="top: 32px;"> <div class="site-logo-div"><a href="https://danzerpress.com/" class="custom-logo-link"> <imgsrc="https://example.com" class="custom-logo" alt="" itemprop="logo" "></a> </div>
wordpress themes js
$( document ).scroll( function(){ var header_parent = header_fixed.parent(); var p_to_top = header_parent.offset().top; var st = $( document ).scrolltop(); if( st > p_to_top && st > 0 ) { $wrap.addclass( 'is-fixed').removeclass( 'no-scroll' ); header_fixed.addclass('header-fixed'); header_fixed.css( 'top', topbar+'px' ); } else { header_fixed.removeclass('header-fixed'); header_fixed.css( 'top', 'auto' ); $wrap.removeclass( 'is-fixed' ).addclass( 'no-scroll' ); } }); }
});
jquery(document).ready(function( $ ) { if ( $('#masthead').hasclass('is-fixed') ) { $('.site-logo-div img').attr('src','second.jpg'); } })( jquery );
Comments
Post a Comment