javascript - Replicate click inside contenteditable <div> with spellcheck -


chrome's native spell check won't work on contenteditable <div> unless user clicks <div>, makes sense. if i'm adding contenteditable <div> dynamically, there way replicate user clicking <div>> spell check work? tried using jquery:

 $('#div-id').click(); 

and

 $('#div-id').trigger('click'); 

but these didn't work. help? jquery or javascript works me.

as comment mentioned, bringing focus element programmatically work enable spellcheck. might undesirable due focus being changed element. here complete solution (not using jquery still work it):

var oldfocus = document.activeelement;  div.focus();  if (oldfocus) {     oldfocus.focus(); } else {     div.blur(); } 

this saves focused element before focusing div in order enable spellcheck. then, focus returned old element (if there 1 had focus), otherwise makes nothing focused.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -