title: Is it impossible to separate javascript from HTML?
body: <p>To be specific, I'm talking about avoiding this type of code:</p>
  
  <pre><code>&lt;input type='text' id='title_33' class='title'
    onfocus='updateCharsLeft(33);' 
    onkeypress='updateCharsLeft(33);' /&gt;
  </code></pre>
  
  <p>Here I would like to put the <code>onfocus</code> and <code>onkeypress</code> event handles separately, i.e in a .js file. Like this:</p>
  
  <pre><code>$(document).ready(function()
    {
      $(".title").focus(updateCharsLeft);
      $(".title").keypress(updateCharsLeft);
  );
  </code></pre>
  
  <p>However here the problem is that the ID of the textbox needs to be passed onto the function <code>updateCharsLeft()</code>. It would suck to have to extract out the id from the ID of the textbox in that function, so it would actually be cleaner to just put in the event handlers within the HTML code.</p>
  
  <p>Thoughts?</p>