+ Start a Discussion
Dileep KatariDileep Katari 

How to display text values one click after another?

Three cities 
First Click on the lightning card
First city should display and continue to display
Second click on the lightning card
Second city should display and continue to display
Third click on the lightning card
Third city should display and continue to display

Ex : Upon first click, Tirupati should display 
Upon second click, Nellore should display
Upon third click, Kanchipuram should display
and finally all three city values shoudl continue to display like that 

I could come up with the below code but it is static. I am new to LWC, please help. Thank you.

JS : 
import { LightningElement,track } from 'lwc';
export default class ConditionalRenderingExample extends LightningElement {
  @track cityList =  ['Tirupati', 'Nellore', 'Kanchipuram'];
   this.city = target.event.value;

       <lightning-card onclick={showCityHandler}>
         <template for:each={cityList} for:item="city">
               <p key={city}>{city}</p>
Best Answer chosen by Dileep Katari
Soyab HussainSoyab Hussain
Hi Dileep Katari,

Use this code this will help you.
import { LightningElement,track } from 'lwc';
export default class ConditionalRenderingExample extends LightningElement {
  count = 0;
  @track selectedCity; 
  @track cityList =  ['Tirupati', 'Nellore', 'Kanchipuram'];
      if(this.count && this.count === 3) {
        this.count = 0;
      this.selectedCity = this.cityList[this.count];
   <lightning-card onclick={showCityHandler}>
     <template for:each={cityList} for:item="city">
           <p key={city}>{city}</p>
If you found it useful please appreciate my efforts and mark it as the best answer.

LinkedIn:  https://www.linkedin.com/in/soyab-hussain-b380b1194/