Dynamically changing logo on scroll function [closed]

I’m assuming the file you’re trying to display is located in your theme folder.

You can use get_template_directory_uri to get the path of your currently activated theme’s root folder.

If you’re looking to support child themes get_stylesheet_directory_uri() will look in the currently activated child theme’s folder if a child theme is in use.

If you must have your JavaScript in a seperate file, you should look into how to pass PHP variables to your JavaScript file with wp_localize_script(). This is pretty straight forward.

I usually pass a variable called themeUrl containing the URL of the theme folder and baseUrl containing the base URL of my site to my JavaScript.