S
S
sergo5732021-06-21 20:29:27
JavaScript
sergo573, 2021-06-21 20:29:27

How to combine two scripts into one (window close and scroll up)?

Hello.
There is a script that closes a certain div block after selecting any option in the select.
But the problem is that on the mobile version, when selecting select, the screen goes down a little, how to combine the scroll and close script in one action?
Script to close div when option is selected:

<script>
    jQuery(document).ready(function() {
   jQuery("#block").change(function() {
      if(jQuery(this).find("option:selected").val()) {
        jQuery(".block-main").addClass('block_open');
      }
   });
});
</script>

Scroll up script:
$('html, body').animate({scrollTop: 0}, 1000);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question