简体   繁体   中英

How to focus on a textarea

After my user enters text into a form field I want to force the cursor to jump to the next field, by doing something like

$('#senderName').focus();

This works as long as the next field is an input element. It doesn't work when the next input is a textarea . Is there any way to force the cursor to jump to a textarea ?

Thanks

Works for me!

Fiddle here

<textarea id="myid"></textarea>

$("#myid").focus()

tabindex=1添加到textarea

<textarea id="senderName" tabindex="1"></textarea>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM