title: Struggling to get if statement to work in Javascript with JQuery
body: <p>The aim of this code is to alter a piece of text on a page so that it is changed from the word reported to pending upon clicking a button. I want to write an if statement so that an error message will appear should the text already read pending.</p>
  
  <pre><code>$(document).ready(function(){
    &lt;?php echo "$(\"#ack".$i."\").click(function(){"; ?&gt;
      &lt;?php echo "if ($(\"#status".$i."\").val() == \"Pending\")"; ?&gt;
        alert("boo"); 
      else 
        &lt;?php echo  "$(\"#status".$i."\").text('Pending');"; ?&gt;
    });
  });
  </code></pre>
  
  <p>Currently the web app just ignores the if statement; the alert never appears when the button is clicked on an row which already has the status pending. Am I taking the right approach to this? What should I change in the if statement so that JS will check the value of status and open the alert if it contains the text "pending"?</p>