Created
October 9, 2022 02:02
-
-
Save tararoutray/6474823cf93429fc56835eaac7645578 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const selectRadioCard = (cardNo) => { | |
/** | |
* Loop through all radio cards, and remove the class "selected" from those elements. | |
*/ | |
const allRadioCards = document.querySelectorAll(".radio-card"); | |
allRadioCards.forEach((element, index) => { | |
element.classList.remove(["selected"]); | |
}); | |
/** | |
* Add the class "selected" to the card which user has clicked on. | |
*/ | |
const selectedCard = document.querySelector(".radio-card-" + cardNo); | |
selectedCard.classList.add(["selected"]); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment