Answer the question
In order to leave comments, you need to log in
Why isn't the function called inside the click() event?
Greetings. Here is the lamer jquery code for consideration.
In this code, I implemented two main events: a click on the sandwich and a shadow that appears and dims the entire site after clicking on the sandwich.
Sandwich clicks and shadow clicks should do the same thing, and in order not to copy sandwich click events into shadow clicks, I created a function for the sandwich event. But the function doesn't want to be called ("navEvents() is not defined"(c) - Console) when the shadow is clicked.
//Sandwitch click
sandwitch.click(function(){
function navEvents() {
sandwitch.toggleClass('open');//Burger animation
shadowCover.fadeToggle();//Shadows appearance,
moveOutNav.toggleClass('add-shadow');
$('.container').toggleClass('open-sidebar');//Nav appearance
if($(document).width() <= 768) {//If less than 768px, red strap fades and resize burger
redPartners.fadeToggle();
sandwitch.toggleClass('marg-top');
sandwitchPease.toggleClass('height-up');
}
if(docWidth > 768 && docWidth < 1366) {//Resized red strap
if(redPartners.width() == 752) {
redPartners.animate({
width: 500
}, 400);
} else {
redPartners.animate({
width: 752
}, 400);
}
}
}
navEvents();
});
//Shadow click
shadowCover.click(function() {
navEvents();
});
Answer the question
In order to leave comments, you need to log in
так она и не определена.
вернее она определена, но видит ее только сендвич.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question