Conditionally show Image on dynamic item page

I have a dynamic item page containing an image linked to the dataset. The dataset has a FieldX. If FieldX = “YES” I want the iamge to show; otherwise, I want it hidden.

this is the code i have already and it hides the image but doesnt show it

$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => {
let activeDynamicItem = $w(“#dynamicDataset”).getCurrentItem();
let fieldX = activeDynamicItem[“Show”];
if (fieldX && fieldX ===“Show”) {
$w(“#image14”).show();
} else {
$w(“#image14”).hide();
}});
});

Can someone please show me what i need to do to the code to make it work? I’ve been unable to adapt the code myself.

Thanks

i have figured it out!!
i had some typos in my code :slight_smile: see below

$w.onReady( function () {
$w(“#dynamicDataset”).onReady(() => {
let activeDynamicItem = $w(“#dynamicDataset”).getCurrentItem();
let fieldX = activeDynamicItem[“show”];
if (fieldX && fieldX ===“YES”) {
$w(“#image14”).show();
} else {
$w(“#image14”).hide();
}});
});

Hello Brenden , im trying to do the same thing but in my case i want to show or hide a button! i copied you code and chagem #image for #button but it only hide de button, dosent show it