I have the following code
$(document).ready(function() {
$("#myTextArea").focus(function() {
$("#myTextArea").animate({ "height": "75px"}, "normal");
return false;
});
to expand a textbox when it gets focus. The expand occurs, however the blinking cursor disapears, at least in Firefox!
Edited: The textarea is still focused, and i can type on it.
Why does this happen? Is there a way to show it again?
Thanks in advance
Your
return falsestatement is cancelling thefocusaction 🙂 You only get a cursor when the element is focused, I’d just remove this line from your function.Aside from that,
.focus()in a text area isn’t something you can reclaim easily, because it had a position that matters, you’re better off sticking with a CSS change here:This won’t affect cursor behavior at all and work the saema cross browsers (
focusis still different amongst browsers), but of course won’t animate. The alternative (I haven’t tested this in all browsers) is that you could trigger the focus again with the same args after the animate, restoring the position, like this:You can test this from here, just be sure to check all browsers, as
focusbehavior can vary slightly between them.