Answer the question
In order to leave comments, you need to log in
Confused in the code javascript animation + function what to do?
I'm not strong in javascript, but the essence of what I'm trying to add is this function - (the effect of appearing and disappearing + disappearing time if the cursor is not hovered over the window in this code . And it doesn’t work rather confused :) There are not a few windows on the entire site, if possible not changing the code too much so as not to adjust the windows to the script later. Asking for help SOS SOS
Answer the question
In order to leave comments, you need to log in
In the wrapper block, add a css class with the js prefix, for example js-myFunc.
Next, cache it:
By analogy, add classes to the necessary elements and look for them in the already cached object:
var myButton = funcWrap.find('.js-next-element'),
myBlock = funcWrap.find('.js-my-block');
myButton.on('click', function () {
if (myBlock.hasClass('active')) {
myBlock.removeClass('active');
} else {
myBlock.addClass('active');
}
});
add some specific identifiers, don't be tied to classes you use for styling or other stuff (like href with a specific value). All elements are searched relative to others, not globally. Globally, you can only find the elements for the first time on which you can hang event handlers.
In general, get used to it - local variables, event handlers, searching for elements relative to others (closest, find with context) is good.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question