Baseline Widely available
selectionEnd
㯠HTMLInputElement
ã¤ã³ã¿ã¼ãã§ã¤ã¹ã®ããããã£ã§ã鏿ããã¹ãã®æ«å°¾ã®ã¤ã³ããã¯ã¹ãè¡¨ãæ°å¤ã§ãã鏿ããªãå ´åãããã¯ç¾å¨ã®ããã¹ãå
¥åã«ã¼ã½ã«ä½ç½®ã®ç´å¾ã®æåã®ãªãã»ãããè¿ãã¾ãã
ã¡ã¢: WHATWG ã®ãã©ã¼ã 仿§æ¸ã«ããã¨ã selectionEnd
ããããã£ã¯ textãsearchãURLãtelãpassword ã®åå
¥ååã«ã®ã¿é©ç¨ããã¾ããç¾è¡ã®ãã©ã¦ã¶ã¼ã§ã¯ããã以å¤ã®å
¥ååã« selectionEnd
ããããã£ãè¨å®ããã¨ä¾å¤ãçºçãã¾ããããã«ãããã¹ã以å¤ã®å
¥åè¦ç´ ã§ selectionEnd
ããããã£ã«ã¢ã¯ã»ã¹ããã¨ããã®ããããã£ã¯ null
ãè¿ãã¾ãã
selectionEnd
ã selectionStart
ãããå°ãããªã£ãå ´åã両è
㯠selectionEnd
ã¨æ±ããã¾ãã
éè² ã®æ°å¤ã§ãã
ä¾ HTML<!-- selectionEnd ãéããã¹ãå
¥åè¦ç´ ã§ä½¿ç¨ -->
<label for="color">selectionStart ããããã£ã type=color ã«è¨å®</label>
<input id="color" type="color" />
<!-- selectionEnd ãããã¹ãå
¥åè¦ç´ ã§ä½¿ç¨ -->
<fieldset>
<legend>selectionEnd ããããã£ã type=text ã«è¨å®</legend>
<label for="pin">Input PIN</label>
<input type="text" id="pin" value="impossible PIN: 102-12-145" />
<button id="pin-btn" type="button">PIN correction</button>
</fieldset>
JavaScript
const colorEnd = document.getElementById("color");
const text = document.querySelector("#pin");
const pinBtn = document.querySelector("#pin-btn");
const validPinChecker = /[^\d{3}-\d{2}-\d{3}]/g;
const selectionEnd = text.value.length;
const selectedText = text.value.substring(text.selectionStart, selectionEnd);
pinBtn.addEventListener("click", () => {
const correctedText = selectedText.replace(validPinChecker, "");
text.value = correctedText;
});
// ãã©ã¦ã¶ã¼ã³ã³ã½ã¼ã«ãéãã¦åºåã確èªãã¦ãã ãã
console.log(colorEnd.selectionEnd); // Output : null
çµæ 仿§æ¸ ãã©ã¦ã¶ã¼ã®äºææ§ é¢é£æ
å ±
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4