title: How can i loop over an array to get jquery properties?
body: <p>I have some fields that I want to hide if they are null. I am able to do this with:</p>
  <pre><code>if (json[0].incendio_edificio == null) {
    $(&quot;#dIncendio_edificio&quot;).parent().parent().hide();
  }
  
  if (json[0].hvct_edificio == null) {
    $(&quot;#dHvct_edificio&quot;).parent().parent().hide();
  }
  
  if (json[0].granizo_edificio == null) {
    $(&quot;#dGranizo_edificio&quot;).parent().parent().hide();
  }
  </code></pre>
  <p>What I want to do is put the fields inside a matrix and do the conditional inside a loop, like this:</p>
  <pre><code>const campos_poliza = [
                           [json[0].incendio_edificio, $(&quot;#dIncendio_edificio&quot;)],
                           [json[0].hvct_edificio, $(&quot;#dHvct_edificio&quot;)],
                           [json[0].granizo_edificio, $(&quot;#dGranizo_edificio&quot;)],
                        ];
  
  for (var x in campos_poliza){
    if (x[0] == null) {
      x[1].parent().parent().hide();
    }
  }
  </code></pre>
  <p>This doesn´t give any errors but it keeps showing null fields. How can I achieve this?
  The html is:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div class=&quot;row&quot;&gt;
    &lt;div class=&quot;col s3&quot;&gt;
      &lt;span class=&quot;text-bold text-blue&quot;&gt;Incendio Edificio:&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class=&quot;col s9&quot;&gt;
      &lt;span id=&quot;dIncendio_edificio&quot;&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;row&quot;&gt;
    &lt;div class=&quot;col s3&quot;&gt;
      &lt;span class=&quot;text-bold text-blue&quot;&gt;HVCT Edificio:&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class=&quot;col s9&quot;&gt;
      &lt;span id=&quot;dHvct_edificio&quot;&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;row&quot;&gt;
    &lt;div class=&quot;col s3&quot;&gt;
      &lt;span class=&quot;text-bold text-blue&quot;&gt;Granizo Edificio:&lt;/span&gt;
    &lt;/div&gt;
    &lt;div class=&quot;col s9&quot;&gt;
      &lt;span id=&quot;dGranizo_edificio&quot;&gt;&lt;/span&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>