There are similar questions on this topic but their answers didnt work for my problem.
Im trying to use jQuery's on("click")
to fire a function that simply changes the class of the id which was clicked. But the function is called when the page is loaded and then if you click on what should fire the function it wont.
Here is the html:
<nav>
<ul>
<li id="all" class="tab-current"><a><span>All Departments</span></a></li>
</ul>
</nav>
And here the js:
var $all = $("#all");
$all.on("click", function(){
tabClicked("all");
});
I've also tried this:
$all.on("click", tabClicked("all"));
And this is the function:
function tabClicked(input){
//do some stuff here
}
Any ideas? Thanks in advanced! :)