jQuery code works for console but not in-page.
- by justSteve
I have a form element defined as:
<div class="field">
<div class="name">
<label for="User_LastName">
Last name: <span class="asterisk">*</span></label>
</div>
<div class="value">
<%= Html.TextBox("User.LastName", Model.LastName)%>
<%= Html.ValidationMessage("User.LastName")%>
</div>
</div>
and a jQuery selector that is supposed to detect when the input gets focus and highlight the parent:
$("input").focus(function() {
//watching for an event where an input form comes into focus
$(this)
.parent()
.addClass("curFocus")
.children("div")
.toggle();
});
If i paste this code into firebug's console - things work as planned. However, i'm running this from a 'RenderPartial' .net mvc page. Other jQuery code sitting within the same $(document).ready(function() { block work correctly.
The form uses html helpers to generate the inputs which might complicate the process somewhat - but even so... i'm seeing correct behavior when that code's in console but not in a 'real-time' page.
How do i troubleshoot this?