Click here to Skip to main content
15,881,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm a beginner in jquery. I was wondering if its possiblet o have an if else in button. for example. I have 3 buttons, each one can change the content of a speciic paragraph. when I click one of those buttons, the two other will hide. Can I also do it using switch case?

What I have tried:

I have tried but I little knowledge about this
Posted
Updated 11-Jun-18 9:27am
Comments
Mohibur Rashid 9-Jun-18 8:38am    
the answer is 'you can'
F-ES Sitecore 9-Jun-18 9:12am    
Give the paragraphs a class or a data attribute that you can use to identify them as a group, and you'll also probably need an id on each paragraph so that you can identify them individually. Make them all hidden using the common attribute, then show the one you want to be visible by identifying it by its unique attribute.

1 solution

Yes, of course you can. jQuery is just a library written in JavaScript. So, you'll just want to write your if statement in javascript.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900