Remove a div

A help?
I should remove a div (eg with name div1, it would be a markdown Source) in case there is a cookie in local storage (eg with name cookiedemo) with value “true”.
I don’t understand… I’m in trouble,
if i use js

<script>
if (localStorage.getItem('cookiedemo') !== "true") {
  HERE I SHOULD REMOVE THE DIV;
} else {
    //yes
}
</script>

Is there a stack that does this? or a suggestion code… help?
Thank you

Hi @Gianluca

What is it that you’re trying to do? If a cookie is present, something should not be displayed or executed?

CookieManager by Stacks4Stacks.com will do that for you without any Javascript. It’s free.

Cheers,
Erwin

1 Like

Hi, I need something that checks if a cookie, in localstorace, whose name I decide is true or false. So the condition of having a divisor display based on true or false.
Only PHP COOKIE SWITCH BY @Jannis does this, but sadly it only works in Poster2.
I need it on a page without Poster.
For this I thought to find a solution in javascript.

That’s most probably not a cookie, but a JavaScript local storage object.

What in detail do you want to remove?

Exactly

a div created from a markdown Source stack, which I would put inside the cssBox stack (to give it an ID)

1 Like

element.remove();
It’s the first thing I tried, but I can’t get this to work with if and else conditional statements

I’m sorry… I’m stupid…
it didn’t work (rightfully so) because I placed the script before the markdown stack.

As I saw the link you sent me I noticed that the div must exist first.

It works perfectly.

Thanks @Jannis

2 Likes