Streaming live at 10am (PST)

Toggle text values with interactions


#1

Is it possible to toggle text values with interactions?

Example: Toggle "Show/Hide" text on click.

Thanks!


#2

Hi, you cannot change the text values using the interactions, but you can add a custom click event on the element you want to process code to change the text values of another element. For example, if you have a button with unique id "button1", and you want to change the text for the element with unique id "target1" and have the code check first if the text for the target is set to Hide or Show when the button is clicked, and change those values depending on the state of the text label, you could past the following function to your Before Body panel of the Custom Code section of Site Settings.

<script>

    $( "#button1" ).click(function() {

      if ($("#target1").text == 'Hide') {

        $("#target1").text('Show');

        } else {

        $("#target1").text('Hide');


        }

    });

</script>

I hope that helps you. Cheers !


#3