title: How to reference to element by name if name is array
body: <p>So here is this element:</p>
  
  <pre><code>&lt;TD&gt;&lt;INPUT type="text" name="when"/&gt;&lt;/TD&gt;
  </code></pre>
  
  <p>I can call a function by</p>
  
  <pre><code>  $(document).ready(function() {
      $('input[name=when]').datepicker();
    });
  </code></pre>
  
  <p>This works fine.
  (When I click the element, a datepicker shows up).</p>
  
  <p>But what if this is the element?</p>
  
  <pre><code>&lt;TD&gt;&lt;INPUT type="text" name="when[]"/&gt;&lt;/TD&gt;
  </code></pre>
  
  <p>Then this does not work:</p>
  
  <pre><code>  $(document).ready(function() {
      $('input[name=when[]]').datepicker();
    });
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>So thank you for answering me guys, I did not know this.
  However. I let the users add rows to the table dynamically so each added row should inherit this function. Unfortunately it does not work in the dynamically created rows:</p>
  
  <pre><code>    function setClass() {
              $('input[name="when[]"]').datepicker();
  //or $('input[name=when\\[\\]]').datepicker();
          }
  </code></pre>