I'm using following JavaScript code to slideUp and slideDown different divs based on theirs link options:
Javascript / jQuery:
function toggleDiv(option) {
$('.content-box').slideUp();
$('#' + option).slideDown(300);
}
HTML:
<li><a class="active" href="javascript:toggleDiv('toggle1')">Toggle 1</a></li>
<li><a href="javascript:toggleDiv('toggle2')">Toggle 2</a></li>
The whole code works perfectly, however what I would like to do is that the class="active" switches to the actual link that user has pressed. I heard about some attribute method or something similiar bur have no ideea how to proceed. So I would appriciate any help from you.
By the way, why is the code working smoothly in Firefox/Chrome but is laggy in Safari?
Check the JSFiddle here: https://jsfiddle.net/3vfwdL34/ For some reason it won't work in JSFiddle but the same code works fine in a normal .html file.