See if ContentEditable div has focus

后端 未结 4 2031
独厮守ぢ
独厮守ぢ 2021-02-14 07:25

I\'m attempting to check whether or not a contenteditable div has focus, but I\'m having some trouble. Here\'s my code so far:

if ($(\"#journal-content:focus\")         


        
4条回答
  •  长发绾君心
    2021-02-14 07:35

    You can try this

    if ($("#journal-content").is(":focus")) {
    ...
    

    Maybe if you'll tell us what are you trying to achieve we'll be of a more help. Meanwhile, you can have a read here: http://api.jquery.com/focus-selector/.

提交回复
热议问题