function makeActive(a) { const items = document.querySelectorAll('.tab-active'); if (items.length) items[0].className = null; a.className = 'tab-active'; } <a href="" className="tab-active" onClick={(e) => {makeActive(e.target)}}>Moulds</a> <a href="" className='tab' onClick={(e) => {makeActive(e.target)}}>Fractionalization</a>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter