title: How can i simplify show/hide div when using onchange event?
body: <p>i currently have a bunch of divs and a dropdown using onchange event when selecting it displays the div and hide them onchange as well. currently i am showing one div at a time and everything works well but i have too many codes. is there anyway i can simplify my code?</p>
  
  <p>Javascript:</p>
  
  <pre><code>&lt;script&gt;
      function changeDiv(val)
      {
          var id = val;
          if (id == '1')
          {
              $('#div_1').css('display','table-row');
              $('#div_2').css('display','none');
              $('#div_3').css('display','none');
              $('#div_4').css('display','none');
          }
          if (id == '2')
          {
              $('#div_2').css('display','table-row');
              $('#div_1').css('display','none');
              $('#div_3').css('display','none');
              $('#div_4').css('display','none');
          }
          if (id == '3')
          {
              $('#div_3').css('display','table-row');
              $('#div_1').css('display','none');
              $('#div_2').css('display','none');
              $('#div_4').css('display','none');
          }
          if (id == '4')
          {
              $('#div_4').css('display','table-row');
              $('#div_1').css('display','none');
              $('#div_2').css('display','none');
              $('#div_3').css('display','none');
          }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Select menu</p>
  
  <pre><code>&lt;select class="seletmenu" onChange="changDiv(this.value)"&gt;
      &lt;option value="1"&gt;Select 1&lt;/option&gt;
      &lt;option value="2"&gt;Select 2&lt;/option&gt;
      &lt;option value="3"&gt;Select 3&lt;/option&gt;
      &lt;option value="4"&gt;Select 4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Divs</p>
  
  <pre><code>&lt;div id="div_1"&gt;
      &lt;div&gt;Testing select 1&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="div_2"&gt;
      &lt;div&gt;Testing select 2&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="div_3"&gt;
      &lt;div&gt;Testing select 3&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="div_4"&gt;
      &lt;div&gt;Testing select 4&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>