How to Hide/Show an Element with a Button in Webflow

This post will teach you how to hide/show an element with a button in Webflow, why you might want to implement this interactive feature on your site, and how the cloneable works to create dynamic content interactions.

TABLE DES MATIÈRES
Ovidiu

How to hide/show an element with a button in Webflow

Les registres des membres sont nécessaires

https://www.memberstack.com/scripts/toggle-item-visibility

Tutoriel

Clonable

Pourquoi/Cas d'utilisation

- Shorten pages by making unessential content available only on demand.

- Improve your site’s design and flow.

Using a button to hide or show elements on a Webflow site

Sometimes there are things you want to have on a page but don’t necessarily want them in full view at all times – e.g. FAQ accordions – you don’t need all the answers visible at all times, especially if they’re long.

This guide will show you how to hide content behind a link or a button and only make it available to those users who wish to see it.

To hide or show elements using a button on your Webflow site, we’re going to use MemberScript #124 – Toggle Item Visibility. Follow the link to get the code you’ll need to add to your page and watch a video tutorial on how to set everything up.

Setting it up

For this to work, you’re going to need to create a button or link for showing the content, another one for hiding it, and then the content itself.

Once you’ve created and styled everything, go ahead and add the following attribute to the show button:

· ms-code-vis-show=”x”

On to the hide button, add this attribute to it:

· ms-code-vis-hide=”x”

Now for the content itself, add these attributes to it:

· ms-code-vis-item=”x”

· ms-code-vis-default=”hide” – this attribute tells it what its default state should be

You’ll notice that these attributes all have the same value and that is only to match them up with each other. The value can be anything you want and if you’re using multiple instances of hidden content on your page, you can use different values to match the buttons to the content they’re supposed to show or hide.

Making it work

Now that you’ve got everything set up in Webflow, all you need to do is add the MemberScript #124 custom code to your page, before the closing body tag.

Conclusion

That’s everything, you can now go ahead and test the buttons on your live site.

Si vous souhaitez utiliser notre projet de démonstration pour commencer, cliquez simplement sur le bouton ci-dessous pour l'ajouter à votre site Webflow.

Our demo can help you add links or buttons to your Webflow site that show or hide content when interacted with.

Take me to Cloneable!

Ajoutez des adhésions à votre projet Webflow en quelques minutes.

En savoir plus

Plus de 200 composants Webflow clonables gratuits. Aucune inscription n'est nécessaire.

Voir la bibliothèque

Ajoutez des adhésions à votre projet React en quelques minutes.

Commencer
Qu'est-ce que Memberstack ?

Auth & paiements pour les sites Webflow

Ajoutez des logins, des abonnements, du contenu à accès limité, et plus encore à votre site Webflow - facile et entièrement personnalisable.

En savoir plus
Commencer à construire

Essayez Memberstack et découvrez ce que vous pouvez construire !

Memberstack est 100% gratuit jusqu'à ce que vous soyez prêt à vous lancer - alors, qu'attendez-vous ? Créez votre première application et commencez à construire dès aujourd'hui.