title: Cannot set property 'class' of undefined
body: <p>I'm certain I'm doing something stupid, or missing something silly but I get the follow 2 error messages, from client side onClick of a button:</p>
  <blockquote>
  <p>Cannot set property 'class' of undefined</p>
  <p>Cannot set property 'scrollTop' of null</p>
  </blockquote>
  <p>All I'm trying to do is style an inputTextArea, and then scroll to the top of a scrollable content div that I have.</p>
  <pre><code>    document.getElementById(x$(&quot;#{id:obj1Error}&quot;).Attributes[&quot;class&quot;] = &quot;has-error&quot;);
      var myDiv = document.getElementById(x$(&quot;#{id:contentWhiteBackground}&quot;));
      myDiv.scrollTop = 0;
  </code></pre>
  <p>Any pointers appreciated. Cheers</p>
  <p>UPDATE:</p>
  <p>Client code on button:</p>
  <pre><code>// Make sure user has entered content into the first objective at minimum
  var objcolparent = document.getElementById(&quot;ObjColOuter&quot;).children[0];
  var objValue = objcolparent.getElementsByTagName(&quot;TEXTAREA&quot;)[0].value;
  
  if(objValue ==&quot;&quot;){
  var o = {};
  o.title = &quot;Validation Failed&quot;;
  o.body = &quot;You must enter at least one objective before submitting&quot;;
  o.alertIcon = &quot;fa-thumbs-down fa-lg&quot;;
  o.alertType = &quot;danger&quot;;
  
  var myDiv = document.getElementById(&quot;#{id:contentWhiteBackground}&quot;);
  //document.getElementById(&quot;#{id:obj1Error}&quot;).className = &quot;has-error&quot;;
  myDiv.scrollTop = 0;
  bootAlert.show('alertServer',JSON.stringify(o));
  return false;
  }
  
  if(confirm(&quot;Are you sure you want to submit your objectives?&quot;)){
  return true;
  }else{
  return false;
  }
  </code></pre>
  <p>Code on xpage, which contains the obj1Error div:</p>
  <pre><code>&lt;xp:repeat id=&quot;repeat1&quot; rows=&quot;100&quot;
                              value=&quot;#{viewScope.fields}&quot; var=&quot;fieldName&quot;&gt;
  
                              &lt;xp:text escape=&quot;true&quot;
                                  id=&quot;computedField4&quot; styleClass=&quot;h5&quot;&gt;
  
  
                                  &lt;xp:this.value&gt;&lt;![CDATA[#{javascript:&quot;Objective &quot;+@RightBack(fieldName, 16)}]]&gt;&lt;/xp:this.value&gt;
                              &lt;/xp:text&gt;
                              &lt;br /&gt;
                              &lt;xp:div id=&quot;obj1Error&quot;&gt;
  
                                  &lt;xp:text escape=&quot;true&quot;
                                      id=&quot;computedField1&quot; styleClass=&quot;h6&quot;&gt;
  
  
  
                                      &lt;xp:this.value&gt;&lt;![CDATA[#{javascript:&quot;Details&quot;}]]&gt;&lt;/xp:this.value&gt;
                                  &lt;/xp:text&gt;
                                  &lt;xp:inputTextarea
                                      id=&quot;inputTextarea1&quot; style=&quot;height:100px;resize:none;&quot;
                                      showReadonlyAsDisabled=&quot;true&quot;&gt;
                                      &lt;xp:this.value&gt;&lt;![CDATA[#{document1[fieldName]}]]&gt;&lt;/xp:this.value&gt;
                                      &lt;xp:this.disabled&gt;&lt;![CDATA[#{javascript:try{
  
  var strStatus:string = document1.getItemValueString(&quot;status&quot;); 
  var booDisabled:boolean = true;
  
  if(strStatus == &quot;New&quot; || strStatus == &quot;Draft&quot; || strStatus == &quot;Returned&quot;) {
  booDisabled = false;
  }
  
  return booDisabled;
  
  }catch(e){
  writeToLog(&quot;Error - ccObjectives disable objective details: &quot; + e);
  }}]]&gt;&lt;/xp:this.disabled&gt;
  
                                  &lt;/xp:inputTextarea&gt;
                              &lt;/xp:div&gt;
                              &lt;br /&gt;
                          &lt;/xp:repeat&gt;
  </code></pre>