WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a little trouble binding the theme customizer live preview javascript to an HTML <img src>- more specifically it is my logo.

Here how the html looks on the page(which is fine and dandy):

<a class="footerlogo" href="#top"><img src="<?php echo mytheme_theme_mod( 'footer_logo' ); ?>" /></a> </div>

Now my problematic part is the JS - Here are my first two attempts. Both not working.

Attempt 1:

    /** Footer logo */
wp.customize( 'mytheme_footer_logo', function( value ) {
    value.bind( function( to ) {
        $( '.footerlogo img src' ).html( to );
    } );
} );

Attempt 2:

/** Footer logo */
wp.customize( 'mytheme_footer_logo', function( value ) {
    value.bind( function( to ) {
    var footer = $( '.footerlogo img' );

     footer.attr( 'href', to );

    } );
} );

Can anyone give me assistance on this?

share|improve this question

Oops, it seems that I accidentaly used the wrong tag, I used href instead of src. Simple fix:

/** Footer logo */
    wp.customize( 'mytheme_footer_logo', function( value ) {
        value.bind( function( to ) {
        var footer = $( '.footerlogo img' );

         footer.attr( 'src', to );

        } );
    } );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.