| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/API/Text/splitText | [Back] [Original] |
Get to know MDN better
newNode = textNode.splitText(offset)
IndexSizeError DOMException16
NoModificationAllowedError DOMException<p>foobar</p>
const p = document.querySelector("p");
// <p>
const foobar = p.firstChild;
// 'foobar' 'foo' 'bar'
// 'bar' const
const bar = foobar.splitText(3);
// <u> ' new content '
const u = document.createElement("u");
u.appendChild(document.createTextNode(" new content "));
// <u> 'bar'
p.insertBefore(u, bar);
// : <p>foo<u> new content </u>bar</p>
| DOM # ref-for-dom-text-splittext |
TextAbortControllerAbortSignalAbstractRangeAttrCDATASectionCharacterDataCommentCustomEventDOMErrorDOMExceptionDOMImplementationDOMParserDOMTokenListDocumentDocumentFragmentDocumentTypeElementEventEventTargetHTMLCollectionMutationObserverMutationRecordNamedNodeMapNodeNodeIteratorNodeListProcessingInstructionQuotaExceededErrorRangeShadowRootStaticRangeTreeWalkerXMLDocumentXPathEvaluatorXPathExpressionXPathResultXSLTProcessor| Web Proxy Viewer | New URL | Original Page |