Interactive online courses HTML Academy
2026-03-09 10:57 Diff

We have already learned how to address collection elements by index. In order for the tooltips to work, you need to add click handlers to the button-words in the tooltipButtons collection.

An intern who worked on the tooltip project before us found the first button and only added a handler to it.

tooltipButton.onclick = function () { tooltip.classList.add('opened'); };

You need to add the exact same handler to the second button. Copy and paste the click handler that the intern wrote. After that, modify both handlers so that they are added to the collection elements:

tooltipButtons[0].onclick = function () { tooltip.classList.add('opened'); }; tooltipButtons[1].onclick = function () { tooltip.classList.add('opened'); };

This way the code is more understandable, and thanks to the indices, we can be sure that we haven’t missed a button. After we change the code, a separate variable for the first button will no longer be needed. Remove it and make sure that when you click on each button a pop-up appears.