title: Passing id attribute in if else statement
body: <p>I want to do if else condition that call out the id in the html. I display a small snippet of my code, but the result doesn't come out accordingly to the condition given. It only display the the last alert('*New Passwords do not match'). </p>
  
  <p>I have google on regarding this. The closes I can find is <a href="https://stackoverflow.com/questions/19304343/using-the-id-for-if-condition">Using the id for if condition</a>, however this only can be done by passing id in the 'div' element. </p>
  
  <p>Is there any other ways to do something quite similar to my code? I know my syntax is not 100% correct, that's why I need an expert advice. Thank you for your time in advance</p>
  
  <p><strong>Here is the if else statement</strong></p>
  
  <pre><code>   if( $('new_pwd').attr('id')  === "") {
              alert('*New Password Empty');
      } else if ( $('retype_pwd').attr('id') === "") {
              alert('*Retype Password Empty');
      } else if( $('new_pwd').attr('id') != $('retype_pwd').attr('id')) {
              alert('*New Passwords do not match') ;
      };      
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;table&gt;
     &lt;tr&gt;
        &lt;td&gt;New Password&lt;/td&gt;
        &lt;td&gt;&lt;input id="new_pwd" type="password" name="new_password"&gt;&lt;/input&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
        &lt;td&gt;Retype Password&lt;/td&gt;
        &lt;td&gt;&lt;input id="retype_pwd" type="password" name="retype_password"&gt;&lt;/input&gt;&lt;/td&gt;
     &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>