+ 6

[Solved] Why doesn't the following code snippet work?

This code is part of my Login page code. The issue is when i click on 'Don't have an account?' button i want to remove class 'hide' from 3 elements (textbox and two buttons).However the class 'hide' from 'Create a new account' button doesn't get removed.WHY?? Here's my code: https://code.sololearn.com/WBxPS3eoUqvp/#html The comments 1,2,3 are the elements with class 'hide'. The comment 'errored button' represents the button whose class isn't removed.

22nd Mar 2020, 11:57 AM
$hardul B
$hardul B - avatar
2 Answers
+ 6
Sorry, not sure about the code. But, have you looked into the element.classList.toggle("className") dom api? It should simplyfy your code drastically Mdn doc: https://developer.mozilla.org/en-US/docs/Web/API/Element/classList Check the js section(from line 66) for code in action. https://code.sololearn.com/W8L9032D2qdO/
22nd Mar 2020, 12:20 PM
Lord Krishna
Lord Krishna - avatar
+ 1
Thank you Lord Krishna i will surely try to use this.. Edit:It works... I had used it yesterday without the if statement.. Thank you so much!
22nd Mar 2020, 12:31 PM
$hardul B
$hardul B - avatar