Created
March 17, 2021 21:11
-
-
Save phpmaps/cac4ddf48cba7fbcf48f7352dcd5edbb to your computer and use it in GitHub Desktop.
contentEditable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stackoverflow.com/questions/6536166/how-to-find-absolute-or-relative-position-of-last-letter-inside-an-input-field | |
| <div id="textbox"> | |
| <span id="edit" contentEditable></span> | |
| <span id="end"></span> | |
| </div> | |
| <div id="report">x:? , y:?</div> | |
| // css | |
| #textbox { | |
| border: solid black 1px; | |
| min-height: 1em; | |
| white-space: nowrap; | |
| } | |
| // javascript | |
| $(function() { | |
| $('#textbox').click(function() { | |
| $('#edit').focus(); | |
| }); | |
| $('#edit').keypress(function() { | |
| var endoff = $('#end').offset(); | |
| $('#report').html('x:' + endoff.left + ' , y:' + endoff.top); | |
| }); | |
| }); |
Author
useEffect(() => {
function listener() {
setShowCalendar(false);
}
document.addEventListener("click", listener);
return () => {
document.removeEventListener("click", listener);
};
}, []);
Author
.test {
pointer-events: none
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.