title: How to scroll after submit when page refresh and PHP set color of label to red to div with ID form?
body: <p>My problem is when I click submit it refresh page when page is refreshed it stays on top without scrolling to div with id form? </p>
  
  <p>jQuery:</p>
  
  <pre><code>$(document).ready(function(){
      if($('label').length &gt; 0){
           $('label').each(function(){  
             if($(this).css('color') == 'red'){
              alert('test');
                $('html, body').animate({
                  scrollTop: $("form").offset().top
                }, 1000);
             }
           });
      }
  });
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post" action="" name="ats_form"&gt;
    &lt;div id="form" class=" ui-body ui-body-d"&gt; &lt;!-- element where I want to scroll --&gt;
      &lt;fieldset&gt;
        &lt;legend&gt;
           &lt;b&gt;Kontaktní osoba&lt;/b&gt;
        &lt;/legend&gt;
         &lt;div data-role="fieldcontain"&gt;
           &lt;label for="f_FName"&gt;Jméno *&lt;/label&gt; &lt;!-- if this label is red, php script check input with regular expression when it is not filled or name is not enter properly then it set this label attribute css to color: red; --&gt;
           &lt;input id="f_FName" class="ui-input-text ui-body-d ui-corner-all ui-shadow-inset" type="text" value="" size="30" name="f_FName"&gt; &lt;!-- this is input that php check --&gt;
         &lt;/div&gt;
       &lt;/fieldset&gt;    
     &lt;/div&gt;
     &lt;input class="btnform ui-btn-hidden" type="submit" name="Submit" value="Odeslat" aria-disabled="false"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>HTML after php validation if input is for example empty or with wrong value:
      same structure as previous
        Jméno *
      same structure as previous</p>