G
G
godsplane2020-04-29 10:23:49
JavaScript
godsplane, 2020-04-29 10:23:49

Why does the script work every other time?

On this page https://www.ydacha.org/taunhaus-100-kv-m-udacha-ju...
The documentation section at the very bottom should open as a spoiler.
The elementary script works every other time, sometimes you need to refresh the page to make it work, sometimes it just works. What could be the reason? Are there any errors in the console? Worth autooptimize , but I chopped it off, it only got worse.
The script itself:

// Раздел с документами
function openDocs($popup, height) {
  var $doc_box = $popup.find('.documents_box'),
    $popup_box = $popup.find('.popup_box'),
    $arrow = $('.js-open-doc'),
    $bg = $popup.find('.popup_background');

  changePopupHeight($popup);

  $arrow.click(function () {
    console.log('check')
    $doc_box.stop().slideToggle(300);
    $arrow.toggleClass('arrow_up');

  });
}

$('.open-doc-list').click(function() {
  console.log('check')
  $(this)
    .find('.img-block')
    .toggleClass('arrow_up')
    .closest('.documents_block')
    .find('.documents-content')
    .slideToggle(300);
});


If something is not clear, I will answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lord_Dantes, 2020-04-29
@Lord_Dantes

document.ready try wrapping the script in it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question