title: Why my onclick function does not work for scroll to the target element?
body: <p>href to <code>?navito=contact</code> be successful and can add my <code>contact.php</code> file, but the <code>onclick</code> function can't scroll into portfolio id.</p>
  
  <p>php code :</p>
  
  <pre><code>&lt;?php
    $nav = filter_input(INPUT_GET, 'navito');
    if (!isset($nav)) {
       $nav = 'home';
    }
  ?&gt;
  
  &lt;div&gt;
     &lt;a class="page-scroll" href="?navito=contact" onclick ="down()"&gt;Contact&lt;/a&gt;
  &lt;/div&gt;
  
  &lt;section id="portfolio" class="bg-light-gray"&gt;
      &lt;?php
          switch ($nav) {
              case 'home':
                  include_once 'View/home.php';
                  break;
              case 'contact':
                  include_once 'View/contact.php';
                  break;
              default:
                  include_once 'View/home.php';
                  break;
          }
      ?&gt;
  &lt;/section&gt; 
  </code></pre>
  
  <p>JS Code:</p>
  
  <pre><code>function down(){
      var x= document.getElementById("portfolio");
      x.scrollIntoView();
  }
  </code></pre>