title: jQuery add onkeypress doesn't work if use @Html.TextBoxFor
body: <p>My problem is the follow: I use jQuery to add attribute to input, but if this input is generate with @Html.TextBoxFor, the jQuery code doesn´t work... This works if I use input tag.</p>
  
  <p>My jQuery code:</p>
  
  <pre><code>$('#ElementId').attr('onkeypress', 'return MyFunction();');
  </code></pre>
  
  <p>In the page:</p>
  
  <pre><code>@Html.TextBoxFor(m =&gt; m.MyText, new { @class = "Inputcss", id = "ElementId"})
  </code></pre>
  
  <p>UPDATE</p>
  
  <p>The html code:</p>
  
  <pre><code>&lt;input id="ElementId" name="MyText" type="text" value="" style="color: rgb(0, 0, 0);" class="valid"&gt;
  </code></pre>
  
  <p>The 'jQuery' is executed successfully., and recognizes the element.</p>
  
  <p>I know there are other ways to add by jquery and works, but I want to know what is the reason because 'attr' does not work.</p>
  
  <p>thanks for any help!</p>
  
  <p>sorry for my english, if someone corrects the wording thank you.</p>