top of page
Hide & Show Elements

Hide & Show Elements

Hide and show elements in response to user interactions.

Intermediate.png

Intermediate

20K

Published:

January 1, 2020

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

This example hides and shows elements in response to user interactions.

Example Code

Tab 1

.

Tab 2

.

Tab 3

.

This code solution can be complicated.

How We Built It

This example demonstrates how to hide and show different page elements depending on how a user interacts with the page.

 

Hiding an element removes the element from the page, but retains the space where the element used to be. Elements positioned below the hidden element will retain their location and elements positioned behind the hidden element are shown.


In the top section, we hide and show different versions of the same image. Each of the four items that can be added to the backpack, have three images overlaid on top of each other outside the backpack and two images with a hotspot inside the backpack. The images outside the backpack are regular images, an image with the Add button on it and a disabled version of the image. Inside the backpack is a box element that serves as a hotspot, a regular image and an image with an X button on it. We use the onMouseIn, onMouseOut and onClick event handlers of the images and the hotspots to hide and show the appropriate images for each interaction.


In the bottom section, we take a different approach. We have seven different images of the backpack. One image is the plain backpack. The other six images of the backpack are with the different patterns. Instead of overlaying all seven images in the Editor and then hiding and showing them as the user chooses a pattern, we have just one image element. When a user clicks on one of the patterns, we change the backpack that is shown in the image element using the element’s src property.  


Next Steps


  1. Open this example in the Editor to work with the template.

  2. Publish the site.

  3. Learn how to work with examples in Velo.

APIs We Used

Non-code example.

Related Articles

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Collapse Elements

Collapse Elements

Collapse and expand groups of elements.

Intermediate.png

Beginner

Hide and Show an Image

Hide and Show an Image

Show and hide an image according to the clicked button.

Intermediate.png

Beginner

Sticky Header

Sticky Header

Keep the site header visible when a visitor scrolls the page.

Intermediate.png

Beginner

Chess

Chess

Use page elements and interactions to create a user interface for prepackaged code.

Intermediate.png

Advanced

Anchor 2
bottom of page