Active button javascript | Sololearn: Learn to code for FREE!


Active button javascript

Hello friends...I have created a little quiz in which I have added 3 questions with 4 button each ..I want whenever someone click on any button it will change to grey it shows that it is selected.and also tried but failed please help

5/12/2020 5:49:01 PM

Shubham Thakur

4 Answers

New Answer


You are missing 6 closing div tags, that are causing you some problems. Such as not displaying quiz cards one at a time the way you want, and all of the answer buttons becoming gray after one click. You really need to add the closing div tags

+2 Only next buttons are not good


There can be used for example such as following function for selecting buttons. Unfortunatelly the code need to be corrected for right functioning. document.body.addEventListener("click", event => { if ( == "BUTTON") = "4px white solid"; } });


Not getting it.