• I am trying to embed a some php in my javascript to switch out images…

    $(document).ready(function() {
        $('.small-port-images a:nth-child(3)').click(function() {
    	$('.large-port-image img').attr('src', '<?php echo get_stylesheet_directory_uri() ?>/images/large-brigham.jpg');
    	});
    });

    I am not sure if I am approaching this correctly. Any advice?

Viewing 1 replies (of 1 total)
  • Instead of “get_stylesheet_directory_uri”, maybe it should be “get_stylesheet_directory_url“? Other than that, it seems like you’re doing it right, depending on what you’re trying to accomplish. Just know that the function will be echoed into that javascript line when the page is loaded, not when the javascript gets to that line.

Viewing 1 replies (of 1 total)

The topic ‘embed php in javascript to switch out image’ is closed to new replies.