title: Doing URl redirects inside a jQuery statement
body: <p>I have this jQuery code:</p>
  
  <pre><code>jQuery( document ).ready( function( $ ) {
  $('#myform').submit( function() {
  
      if ($('#myform input').is(':checked')) {
  
      } else {
          //alert('Checkbox is not checked!!');
          window.location.replace("http://example.com/product-comparisons/?product-skus=0");
  
      }
  
   });
  </code></pre>
  
  <p>});</p>
  
  <p>I want to redirect to this URL:</p>
  
  <p><a href="http://example.com/product-comparisons/?product-skus=0" rel="nofollow noreferrer">http://example.com/product-comparisons/?product-skus=0</a></p>
  
  <p>If the user clicks the check box without any checked items.</p>
  
  <p>I tried the above code based on this suggestion: <a href="https://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript">How to redirect to another webpage in JavaScript/jQuery?</a></p>
  
  <p>But that won't work. I would appreciate for any inputs and suggestions. Thank you!</p>
  
  <p>UPDATE: This is my HTML COde/a form:</p>
  
  <pre><code>&lt;form action="/product-comparison/" id="myform"&gt;
  &lt;ul&gt;
  &lt;li&gt;
  &lt;input type="checkbox" name="product-skus[]" value="1" id="mycheckbox"&gt;
  &lt;a href="http://example.com/product/translator/"&gt;Translator&lt;/a&gt;100&lt;img width="150" height="150" title="View product" style="" alt="View product" class="attachment-thumbnail" src="http://example.com/wp-content/uploads/2012/12/pic1-150x150.jpg"&gt;&lt;/li&gt;
  &lt;li&gt;&lt;input type="checkbox" name="product-skus[]" value="2" id="mycheckbox"&gt;
  &lt;a href="http://example.com/product/arrows/"&gt;Arrows&lt;/a&gt;120&lt;img width="150" height="150" title="View product" style="" alt="View product" class="attachment-thumbnail" src="http://example.com/wp-content/uploads/2012/12/pic2.jpg"&gt;&lt;/li&gt;&lt;/ul&gt;
  
  &lt;input type="submit" value="Compare"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>However I believe my selector is correct because this diagnostic code (using alerts to make sure jQuery funnels to the right logic) is perfectly working:</p>
  
  <pre><code>jQuery( document ).ready( function( $ ) {
  $('#myform').submit( function() {
  
      if ($('#myform input').is(':checked')) {
          alert('Checkbox is checked, do nothing');
      } else {
  
          alert('Checkbox is not checked!!, do the redirects');
  
  
      }
  
   });
  });
  </code></pre>