title: JQuery: Toggle hidden field's value
body: <p>I've been searching for a while now on how to do this. In my form, I would like to toggle a value back and forth (true &lt;-> false) by click a div.</p>
  
  <p>How do you toggle a hidden field's true/false value using jquery? </p>
  
  <hr>
  
  <pre><code>&lt;input id="myHiddenField" name="my[hidden_field]" type="hidden" value="false"&gt;
  
  &lt;a id="myDiv"&gt;Click Me&lt;/a&gt;
  </code></pre>
  
  <p>I've tried</p>
  
  <pre><code>$('#myDiv').on('click'), (function() {
      var hiddenField = $('#myHiddenField'),
          val = hiddenField.val();
  
      hiddenField.val(val === "true" ? "false" : "true");
  });
  </code></pre>
  
  <p>but nothing :(</p>
  
  <p>jsfiddle:
  <a href="http://jsfiddle.net/MV3A4/2/" rel="noreferrer">http://jsfiddle.net/MV3A4/2/</a></p>