简体   繁体   中英

How can I autofocus using Javascript on newly created element?

I have one input field, if the user hits enter then it'll be disabled and another one created and so on. I want to autofocus the new input field every time I create it, and remove the blue border that's created when I click on it.

If you didn't understand me, see this link .

不,您一次只能关注一个元素。

You can use jQuery 's .focus() event to target the newly created input .

To remove the blue border, remove the outline from the input on :focus using CSS :

input:focus {
  outline: none;
}

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