You need to sign in to do that
Don't have an account?
Amy J
Hide and show text on a single button click
Hi,
I have requirement, when I ckick a button text shoud come and when I ckick the same button the text shoud hide. I'm not able to hide on the same button click. Please assist. Below is my code.
I have requirement, when I ckick a button text shoud come and when I ckick the same button the text shoud hide. I'm not able to hide on the same button click. Please assist. Below is my code.
html- <lightning-button label={ShowText} title="Show text" onclick={handleClick} class="slds-m-left_x-small"></lightning-button> <div style=" margin-top: -30%; left: 550%; margin-left: -30px; background: linear-gradient(#fff, #dbe4eb); border-color:#555 transparent transparent transparent;color: #111; border: 1px solid black;" if:true={showText1}>{textValue}</div> JS- @track ShowText='Show text' @track showText1 = false; textValue = 'Some text value'; handleClick(event){ const label=event.target.label; if(label==='Show text'){ this.Showtext='Hide text'; this.showText1 = true; }else if(label==='Hide text'){ this.Showtext='Show text'; this.showText1 = false; } }
All Answers
try with below.
html
Js:
If this helps, Please mark it as best answer.
Thanks!!
Thank you for your reply. I tried above code but its not getting false. It's getting true on the first click but not getting false on the second click which is my requirement. It should get true on the first click and false on the second click on the same button and so on. Plese let me know if you have any other workaroud.