Calling Function now working
I've got a normal JS function, I'm calling it from a few different jQuery events which is why the code is standalone.
The problem is, it's either not working or it's working twice.
Here's my code. In DevTools, the class of popup flashes like something it happening however the class is not added to the code.
Also when I do a console.log within the togglefunction function it writes two lines every event. No idea why?
Any ideas?
-
$(
document).
ready(
function(){
$(
'.menu-toggle').
click(
toggleFunction);
$(
'nav li').
click(
toggleFunction);
$(
'#results').
click(
toggleFunction);
$(
'#close').
click(
function(){
$(
'.popup').
toggleClass(
'active-popup');
})
function
toggleFunction() {
var
element =
document.
getElementById(
"popup");
element.
classList.
toggle(
"active-popup");
}
})