Hi !
I’m trying to have my event banner in the header collapsed based on one criterion.
Here’s my code but it doesn’t work :
if ($w("#text113").text .contains("Black Friday")) $w("#banniereEvent").collapse();
So basically there’s an event banner in the header, and I want it to collapse if the user is browsing the current event page.
Thanks !
Please try to use the code below (the code should be inside an onReady function):
$w.onReady(function () {
if ($w("#text113").text === "Black Friday") {
$w("#banniereEvent").collapse()
}
});
Hi ! I found out what the solution was shortly after posting this.
My code has been updated to this:
if ($w(“#text113 ”).text.includes(“Black Friday”)) $w(“#banniereEvent ”).collapse();
Your code is correct, but the text should be the exact same, and I needed a function that worked when the whole text contained ‘Black Friday’.
skmedia
November 25, 2019, 11:17pm
4
@tristan-breon-1 Also, make sure it’s $w(‘#text113 ’).text.includes(), as you’re trying to check if the text of the text element includes your query, not the entire element’s object.
@skmedia Yes true, I forgot the mention “.text”, I have updted my post