If I have class .A and class .B and want to switch in between on button click, what’s a nice solution for that in jQuery? I still don’t understand how toggleClass() works.
Is there an inline solution to put it in onclick="" event?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If your element exposes class
Afrom the start, you can write:This will remove class
Aand add classB. If you do that again, it will remove classBand reinstate classA.If you want to match the elements that expose either class, you can use a multiple class selector and write: