Search code examples
prototypejs

prototype focus not work?


this snippet didn't work?

$('reply_form').show().focus();

and also this:

$('reply_form').show();Form.Element.focus('reply_form');

why?

updated

the element is a textarea with an id 'reply_form', and has a inline style with 'display:none;'(i know this is not a best practise, but writing the display style externally in a css file , the show function didn't work as the prototype doc said); the 'show()' part works, but the focus is not.


Solution

  • Hmm, it works well for me:

    HTML code:

    <textarea id="reply_form" style="display:none"></textarea>
    

    JS code:

    $('reply_form').show().focus();
    

    And I'm using Prototype 1.6.0.3. What is your version of library?

    Did you register any event action (onload, onclick) for this? ;-)