title: Escape square brackets when assigning a class name to an element
body: <p>Does anyone know how to escape the square bracket character when setting a class name with jQuery?</p>
  
  <p>Try the following:</p>
  
  <pre><code>$('#txtFirstname').addClass('test[someval]')
  </code></pre>
  
  <p>then</p>
  
  <pre><code>$('#txtFirstname').attr('class')
  </code></pre>
  
  <p>you'll see the class is there.</p>
  
  <p>Now try</p>
  
  <pre><code>$('#txtFirstname').hasClass('test[someval]')
  </code></pre>
  
  <p>FAIL</p>
  
  <p>The only reason I can think of is the square brackets.</p>
  
  <p>And I need these for my jQuery validation you see.</p>