I've got a field on a web page that needs some javascript behaviour when it gains or loses focus, so I attached the appropriate handlers in a $(document).ready to the field.
It all works fine, except if the user focuses the input field before the ready event fires. In this case the behaviour doesn't occur. The old version used onfocus and onblur attributes in the tag itself, which is obviously a very bad way of doing it, but did have the advantage that the behaviour would occur as soon as the input field became visible. Is there a friendlier way of attaching behaviour before the ready event?