title: CSS Class is still displayed when CSS Display is set to none causing JScript ID issues
body: <p>I have a situation where I am stuck and do not know how to solve it.
  I have a contact page that has some calculations that need to be processed and it will not work with Display: block and Display: none.</p>
  <p>My Code is displayed below:</p>
  <pre><code>&lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;style&gt;
      .contactMobile{
          display: none;
      }
      
      .contactDesktop{
          display: block;
      }
  
      @media only screen and (max-width : 667px) {
  
          .contactMobile{
              display: block;
          }
          .contactDesktop{
              display: none;
          }
          }
  &lt;/style&gt;
  
  
  &lt;section class=&quot;contactDesktop&quot; id=&quot;contact&quot;&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
          &lt;form asp-action=&quot;Contact&quot; asp-controller=&quot;Home&quot; method=&quot;POST&quot; role=&quot;form&quot; class=&quot;php-email-form&quot;&gt;
              &lt;input asp-for=&quot;Stats&quot; type=&quot;hidden&quot; value=&quot;99&quot; /&gt;
              &lt;table class=&quot;tg&quot;&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;td class=&quot;tRow1&quot;&gt;
                              contact Top Left
                          &lt;/td&gt;
                          &lt;td class=&quot;tRow2&quot; rowspan=&quot;2&quot;&gt;
                              &lt;div class=&quot;form&quot;&gt;
                                  &lt;div class=&quot;col-md-12 text-center&quot;&gt;
                                      &lt;div class=&quot;row contactDesktop&quot; id=&quot;submit&quot;&gt;
                                          &lt;div id=&quot;chk&quot;&gt;
                                              &lt;div class=&quot;col-md-12&quot; style=&quot;padding:10px!important;text-align:left;&quot;&gt;
                                                  &lt;label class=&quot;text-lg-start&quot;&gt;Add:&lt;/label&gt;
                                                  &lt;input id=&quot;val1&quot; style=&quot;max-width:30px;padding:5px;border:0;text-align:center;color:white&quot; disabled&gt;
                                                  +&lt;input id=&quot;val2&quot; style=&quot;text-align:center;max-width:30px;padding:5px;border:0;color:white&quot; disabled&gt;
                                                  =&lt;input style=&quot;max-width:30px;padding:5px;&quot; name=&quot;honey&quot; id=&quot;honey&quot; oninput=&quot;myFunction(this.value)&quot;&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                          &lt;div id=&quot;buttonCheck&quot;&gt;
                                              &lt;div class=&quot;col-md-12&quot; style=&quot;padding:5px!important;&quot;&gt;
                                                  &lt;div class=&quot;form-group sndBtn&quot;&gt;
                                                      &lt;button type=&quot;submit&quot; style=&quot;border-radius:5px;&quot;&gt;SEND&lt;/button&gt;
                                                  &lt;/div&gt;
                                              &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                      &lt;br /&gt;
                                      &lt;div class=&quot;row&quot;&gt;
                                          &lt;div class=&quot;col-md-12 form-group&quot; style=&quot;color:red; font-size:large; font-weight: 600;&quot;&gt;
                                              &lt;div class=&quot;loading&quot;&gt;Loading&lt;/div&gt;
                                              &lt;div class=&quot;error-message&quot;&gt;&lt;/div&gt;
                                              &lt;div class=&quot;sent-message&quot; style=&quot;background: darkgreen;border-radius:5px;&quot;&gt;Your message has been sent. Thank you!&lt;br /&gt;We will respond ASAP.&lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                          &lt;td class=&quot;tRow3&quot; rowspan=&quot;2&quot;&gt;
                              Contact Right
                          &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td class=&quot;tRow4&quot;&gt;
                              Contact Bottom Left
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
              &lt;/table&gt;
          &lt;/form&gt;
      &lt;/div&gt;
  &lt;/section&gt;
  
  &lt;section class=&quot;contactMobile&quot; id=&quot;contact&quot;&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
          &lt;div class=&quot;row justify-content-center&quot;&gt;
              &lt;div class=&quot;col-md-3 text-center&quot; style=&quot;margin-top:25px;&quot;&gt;
                  Contact US
              &lt;/div&gt;
              &lt;div class=&quot;col-md-6&quot; id=&quot;contactUs&quot;&gt;
                  &lt;div class=&quot;form&quot;&gt;
                      &lt;form asp-action=&quot;Contact&quot; asp-controller=&quot;Home&quot; method=&quot;POST&quot; role=&quot;form&quot; class=&quot;php-email-form&quot;&gt;
                          &lt;input asp-for=&quot;Stats&quot; type=&quot;hidden&quot; value=&quot;99&quot; /&gt;                      
                          &lt;div class=&quot;col-md-12 text-center&quot;&gt;
                              &lt;div id=&quot;submit&quot; class=&quot;contactMobile row&quot;&gt;
                                  &lt;div id=&quot;chkM&quot;&gt;
                                      &lt;div class=&quot;col-md-12&quot; style=&quot;padding:10px!important;text-align:left;&quot;&gt;
                                          &lt;label class=&quot;text-lg-start&quot;&gt;Add:&lt;/label&gt;
                                          &lt;input id=&quot;val1M&quot; style=&quot;max-width:30px;padding:5px;border:0;text-align:center;color:white&quot; disabled&gt;
                                          +&lt;input id=&quot;val2M&quot; style=&quot;text-align:center;max-width:30px;padding:5px;border:0;color:white&quot; disabled&gt;
                                          =&lt;input style=&quot;max-width:30px;padding:5px;&quot; name=&quot;honey&quot; id=&quot;honey&quot; oninput=&quot;myFunctionM(this.value)&quot;&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                                  &lt;div id=&quot;buttonCheckM&quot;&gt;
                                      &lt;div class=&quot;col-md-12&quot; style=&quot;padding:5px!important;&quot;&gt;
                                          &lt;div class=&quot;form-group sndBtn&quot;&gt;
                                              &lt;button type=&quot;submit&quot; style=&quot;border-radius:5px;&quot;&gt;SEND&lt;/button&gt;
                                          &lt;/div&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;br /&gt;
                              &lt;div class=&quot;row&quot;&gt;
                                  &lt;div class=&quot;col-md-12 form-group&quot; style=&quot;color:red; font-size:large; font-weight: 600;&quot;&gt;
                                      &lt;div class=&quot;loading&quot;&gt;Loading&lt;/div&gt;
                                      &lt;div class=&quot;error-message&quot;&gt;&lt;/div&gt;
                                      &lt;div class=&quot;sent-message&quot; style=&quot;background: darkgreen;border-radius:5px;&quot;&gt;Your message has been sent. Thank you!&lt;br /&gt;We will respond ASAP.&lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class=&quot;col-md-3&quot;&gt;&lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/section&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
      var ranVal1 = Math.floor((Math.random() * 10), 2);
      var ranVal2 = Math.floor((Math.random() * 10), 2);
      var ranVal = Math.floor((ranVal1 + ranVal2), 2);
      $(&quot;#val1&quot;).val(ranVal1);
      $(&quot;#val2&quot;).val(ranVal2);
      $('#buttonCheck').css({ 'display': 'none' });
  
      function myFunction(val) {
          if (val == ranVal) {
              $('#buttonCheck').css({ 'display': 'block' });
              $('#chk').css({ 'display': 'none' });
              $(&quot;#Stats&quot;).val(&quot;200&quot;);
          }
      }
  &lt;/script&gt;
  </code></pre>
  <p>This only works to hide the desktop from view when I am in Mobile mode; however, the Math calculations are not working.  Upon a Chrome Inspection, I noticed that even though the Desktop code was not visible on my monitor, it was still present on the html code and is affecting the JavaScript because the IDs are doubled.</p>
  <p>Is there another way for me to only show the html code that is meant for either the Desktop or Mobile?</p>