focus() doesn't work inside colorbox pop-up

前端 未结 6 1716
遇见更好的自我
遇见更好的自我 2021-02-14 11:43

I tried to use focus for first input field on the form. but it doesn\'t work. When I call attr(\"id\") for that input it worked. When I call focus f

6条回答
  •  后悔当初
    2021-02-14 12:37

    It may be happening that when your colorbox is opened its focus goes onto the highest element i.e. body of page. use document.activeElement to find that focus went to which element. Then find iframe or id of your colorbox and then set focus on it

提交回复
热议问题