用戶在此處輸入一些字符串,并且該字符串包含Mahi為子字符串。我試圖將光標(biāo)Mahi放在單擊按鈕的末尾嗎?.html<div id="demo" contenteditable="true"></div><button id="btn" onclick="focusAtMen()"></button>js// lets suppose user input is "Hi.......Mahi, .....?";// here dots may be any charactersfocusAtMen(){var editor = document.getElementById("demo");// set focus on `contentEditable div` and `place cursor at the end` of `Mahi` , thats a user Input.}
將光標(biāo)設(shè)置在可滿足div的子字符串末尾
哆啦的時(shí)光機(jī)
2021-04-09 18:15:46