Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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!

    #298987

    Hi!

    Can you paste the code you tried to use?

    Regards,
    Josue

    #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>

    #299029

    Hey!

    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.