Answer the question
In order to leave comments, you need to log in
How to make it stay in place when you click on the element again?
There is a function that flips pages
<div id="vid"></div>
<div id="func"></div>
<div class="button_capse">
<div id="butVid" name="vid" ></div>
<div id="butFunc" name="func"></div>
</div>
function scrollLeft (name) {
name.on('click', function() {
let $elem = $('#' + $(this).attr('name'));
if ($oldElem.css('left') == '0px') {
$oldElem.animate({left: '2000px'}, 300, function() {$(this).css({'display': 'none', 'left': '-2000px'})})
}
if ($elem.css('left') == '-2000px') {
$elem.css('display', 'block').animate({left: '0px'}, 300)
}
$oldElem = $elem
})
}
let $oldElem = $('#index_wrap')
scrollLeft($('#butVid'))
scrollLeft($('#butFunc'))
Answer the question
In order to leave comments, you need to log in
I found the solution by changing this line
if ($oldElem.css('left') == '0px' && ($oldElem.attr('id') != $elem.attr('id'))) {
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question