-
AuthorPosts
-
August 1, 2014 at 6:55 pm #298887
Hi. I recently updated the theme and tried to use the code block that was provided (very excited about it) But when I tried putting in some javascript, it converted the < and > into their corresponding html entity code, thus breaking the functionality. Thanks!
August 1, 2014 at 11:36 pm #298987Hi!
Can you paste the code you tried to use?
Regards,
JosueAugust 2, 2014 at 12:12 am #298998<script>
function setImage(){
if( jQuery( window ).width() < 570 ){
jQuery( “img[title^=’SMS Marketing Banner’]” ).attr( ‘src’ , ‘/wp-content/uploads/2014/08/ReEngagement-Mobile-ChildPage-Banner.png’ );
}else if( jQuery( window ).width() > 1100 ) {
jQuery( “img[title^=’SMS Marketing Banner’]” ).attr( ‘src’ , ‘/wp-content/uploads/2014/08/ReEngagement-Large-ChildPage-Banner.jpg’ );
} else {
jQuery( “img[title^=’SMS Marketing Banner’]” ).attr( ‘src’ , ‘/wp-content/uploads/2014/08/ReEngagement-Medium-ChildPage-Banner.jpg’ );
}
};
jQuery( window ).resize(function(){
setImage();
});
setImage();
</script>August 2, 2014 at 2:02 am #299029Hey!
I’ve tested the exact same code and it worked as expected. Make sure you are using the latest verion of Enfold (2.9.1).
One more thing, if you plan to include the code on all pages maybe it would be more convenient to use the wp_footer hook:
function add_custom_script(){ ?> <script> function setImage(){ if( jQuery( window ).width() < 570 ){ jQuery( "img[title^='SMS Marketing Banner']" ).attr( 'src' , '/wp-content/uploads/2014/08/ReEngagement-Mobile-ChildPage-Banner.png' ); }else if( jQuery( window ).width() > 1100 ) { jQuery( "img[title^='SMS Marketing Banner']" ).attr( 'src' , '/wp-content/uploads/2014/08/ReEngagement-Large-ChildPage-Banner.jpg' ); } else { jQuery( "img[title^='SMS Marketing Banner']" ).attr( 'src' , '/wp-content/uploads/2014/08/ReEngagement-Medium-ChildPage-Banner.jpg' ); } }; jQuery( window ).resize(function(){ setImage(); }); setImage(); </script> <?php } add_action('wp_footer', 'add_custom_script');
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.