javascript - Tab into a textarea not highlighting the text -
basically, when tab through form, every input field text highlighted, doesn't happen textareas. or ideas appreciated. i've included textarea html below in case.
<textarea onblur="if(this.value==''){this.value='embed code'}" onclick="if(this.value=='embed code'){this.value=''}" name="post.code">embed code</textarea>
use onfocus instead of onclick, getting focus tabbing not dispatch click event (so onclick handler isn't called). note html5 has placeholder attribute script doing.
to select text in textarea, add handler focus event:
<textarea ... onfocus="this.select()" ...
note may annoy users don't expect happen textarea elements.
Comments
Post a Comment