Newer Version Available
Dynamically Showing or Hiding Markup
Use CSS to toggle markup visibility. You could use the <aura:if> tag to do the same thing but we recommend using CSS as it’s the
more standard approach.
This example uses $A.util.toggleClass(cmp, 'class') to toggle visibility of markup.
1<!--c:toggleCss-->
2<aura:component>
3 <ui:button label="Toggle" press="{!c.toggle}"/>
4 <p aura:id="text">Now you see me</p>
5</aura:component>1/*toggleCssController.js*/
2({
3 toggle : function(component, event, helper) {
4 var toggleText = component.find("text");
5 $A.util.toggleClass(toggleText, "toggle");
6 }
7})1/*toggleCss.css*/
2.THIS.toggle {
3 display: none;
4}Click the Toggle button to hide or show the text by toggling the CSS class.