Hiding Dynamic Page elements based on URL

Evening all,

Is it possible to hide elements on a dynamic page based on the URL of the current page?
So as an example:

I have dynamic pages, connected to the same dataset and with a dropdown to flick through the pages. which have the following URLs:
www.mywebsite.com/mydynamicpage/01
www.mywebsite.com/mydynamicpage/02
(The above are made up so click on them at your own risk)

The dynamic page is set up with a text box and an image box and when it is on the page ending “01” I want both elements to show and when it is on “02” I would want the text box to show but the image box to be hidden.

It seems to me that this should be a very simple thing to do using the if function but I have failed to get it to do as I wish and have not been able to find anything online to help with it so I have, once again, come cap in hand for some help please.

Thanks

You could try using wix-location to get the current URL and then use $w(‘#myelement’).collapse() and $w(‘#myelement’).hide() to make the undesired ones disappear

Thanks @gladen - you’ve pointed me in the right direction and a quick glance of the API documentation helped to lead me to the following code:

$w.onReady(function () {
    HideElements();
    });
        
function HideElements () {
 let url = wixLocation.url;
 if (url === "https://www.mywebsite.com/mydynamicpage/02")
    {
        $w('#image1').hide();
        } else {
        $w('#image1').show();
        }
        }