I think I see what you are getting at now. This is for SugarCube.
You first have to set a variable in a passage titled StoryInit. Let’s make the door closed by default.
<<set $doorOpen to false>>
Now for the link… put this in your Start page:
<<link "Open the door">>
<<if $doorOpen eq false>>
<<set $doorOpen to true>>
<<elseif $doorOpen eq true>>
<<set $doorOpen to false>>
<</if>>
<</link>>
Note that this alone with just swap the variable silently and endlessly. There are a lot of ways to update the passage—either by refreshing it, by going to a new passage, or by targeted replacement of a div.
Here is one way to make it refresh the current passage with ‘goto’ then print the $doorOpen variable. It replaces the Start passage above.
<<link "Open the door">>
<<if $doorOpen eq false>>
<<set $doorOpen to true>>
<<elseif $doorOpen eq true>>
<<set $doorOpen to false>>
<</if>>
<<set $this to passage()>>
<<goto $this>>
<</link>>
<<if $doorOpen eq true>>The door is open/You open the door.<<else>>The door is closed.<<endif>>