I have three anchor
tags. Now I wanna add another function which will add a new class to the one which is clicked.
HTML code below
<ul>
<li><a href="#" id="one" onclick="smoothScroll(document.getElementById('secondSection'));addClass(this.id);">About</a></li>
<li><a href="#" id="two" onclick="smoothScroll(document.getElementById('thirdSection'));addClass(this.id);">Portfolio</a></li>
<li><a href="#" id="three" onclick="smoothScroll(document.getElementById('forthSection'));addClass(this.id);">Contact</a></li>
</ul>
And below is my javascript
function changeClass(clicked_id) { document.getElementById('clicked_id').setAttribute("class", "active"); }
But this does not work, what is the problem?
Appreciate any help.