MCPcopy
hub / github.com/aykutkardas/regexlearn.com / setCaretPosition

Function setCaretPosition

src/utils/setCaretPosition.ts:1–6  ·  view source on GitHub ↗
(inputEl: HTMLInputElement, pos: number)

Source from the content-addressed store, hash-verified

1const setCaretPosition = (inputEl: HTMLInputElement, pos: number): void => {
2 if (!inputEl || !inputEl.setSelectionRange) return;
3
4 inputEl.focus();
5 inputEl.setSelectionRange(pos, pos);
6};
7
8export default setCaretPosition;

Callers 2

InteractiveAreaFunction · 0.85
PlaygroundFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected