title: How to reference an id with brackets in jQuery
body: <p>I'm painfully new to jQuery and I need to grab the value on change of a text input box with an id of <code>id[2][t]</code> and display that text in a <code>div</code> to be styled later on (also styled with jQuery).</p>
  
  <p>This is the input box code:</p>
  
  <pre><code>&lt;input id="id[2][t]" name="id[2][t]" maxlength="20" type="text"&gt;
  </code></pre>
  
  <p>This is the div I am trying to display it in: </p>
  
  <pre><code>&lt;div id="textpreview"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>This is what I have tried, among other variation with no success:</p>
  
  <pre><code>$(document).ready(function() {
  
  $('#id\\[2\\]\\[t\\]').change(function() {
    var txtval = $('#id\\[2\\]\\[t\\]').text();
    $("#textpreview").val(txtval);
  });
  
  });
  </code></pre>
  
  <p>I know the brackets are a problem but they need to remain for other reasons. </p>
  
  <p>Any ideas?</p>