focus() not working in safari or chrome

前端 未结 6 2063
别那么骄傲
别那么骄傲 2020-11-30 11:25

I have a div that has been given a tabindex, when the div is focused(click or tabbed to) it does the following:

inserts an input into itself, gives the input focus

6条回答
  •  离开以前
    2020-11-30 11:35

    Although I couldn't find this specifically stated anywhere, .focus() only works on input elements and links. It also isn't supported properly in Chrome and Safari. I posted a demo here to show you what I mean. Also note that focus() and focusin() (v1.4) have the same results.

    So that being determined, try changing your function to .click()

    $("#recipientsDiv").click(function(e){ ... })
    

提交回复
热议问题