title: Not able to tick Checkboxes using JQuery
body: <p>I am having trouble checking checkboxes via JQuery - I have done this:</p>
  
  <pre><code>if(element[1]==3)
    alert('#'+element[0]+'_1');//shows #chk_1
    $('#'+element[0]+'_1').attr('checked', true);
    $('#'+element[0]+'_2').attr('checked', true);
    $('#'+element[0]+'_3').attr('checked', true);    
  }
  </code></pre>
  
  <p>I know it gets to that point because I can see the alert window with the correct variable name. I have also included JQuery and my firebug isn't complaining about any errors, its just nothing is happening.</p>
  
  <p>I have a few other functions which are active on a user click:</p>
  
  <pre><code>onclick="checker($(this).attr('id'));" 
  </code></pre>
  
  <p>Which essentially checks if a user is allowed to tick the checkbox but this shouldn't get activated if I use the above method, correct? Plus I have done the automated ticks in such a way that those rules are preserved and the user is allowed to tick the checkboxes.</p>
  
  <p>I am able to click the checkboxes and those rule checks are done correctly in the checker function.</p>
  
  <p>HELP! I have no idea what's wrong to be frank.</p>
  
  <p>I appreciate nay help.</p>
  
  <h2>Update</h2>
  
  <p>With Pekka's advice I have found that no JQuery function seems to be working for example:</p>
  
  <p><code>$('#'+element[0]+'_1').hide();</code></p>
  
  <p>Did nothing. So it means the ID of the element has a problem? But the element does exist and its the correct name!</p>
  
  <p>I have given the checkbox a value and tried this:</p>
  
  <p><code>alert($('#'+element[0]+'_1').val());</code></p>
  
  <p>I get "undefined" returned! Why?</p>
  
  <h2>Update 2</h2>
  
  <p>Testing if it has been checked:</p>
  
  <pre><code>$('#'+element[0]+'_1').attr('checked', true);
  
  if ($('#'+element[0]+'_1'+':checked').val() !== null) {
     alert('#'+element[0]+'_1');
  }
  </code></pre>
  
  <p>This showed me the alert box. So it seems it is checked but I can not see it?</p>
  
  <h2>Update - Solution</h2>
  
  <p>Don't be a noob like me and wrap JQuery code with: <code>$(document).ready(function() {</code></p>
  
  <p>I managed to waste everyones time having not done this, I think that bit of code is going to become standard for me from now on.</p>
  
  <p>Thank you everyone for the continued help! :) I'll have to give to the person [lillq] that mentioned document load!</p>