| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/API/Text/splitText | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
Text.splitText() Text . sibling .
, , . . , sibling . , .
16 INDEX_SIZE_ERR DOMException throw. NO_MODIFICATION_ALLOWED_ERR DOMException throw.
replacementNode = textnode.splitText(offset);
<body>
<p id="p">foobar</p>
<script type="text/javascript">
var p = document.getElementById("p");
var textnode = p.firstChild;
// foo bar
var replacementNode = textnode.splitText(3);
// ' span contents ' span
var span = document.createElement("span");
span.appendChild(document.createTextNode(" span contents "));
// 'bar' span
p.insertBefore(span, replacementNode);
// : <p id="p">foo<span> span contents </span>bar</p>
</script>
</body>
| Specification |
|---|
| DOM # ref-for-dom-text-splittext |
Text .Node.normalize.This page was last modified on 2023 7 30 by MDN contributors.
TextAbortControllerAbortSignalAbstractRangeAttrCDATASectionCharacterDataCommentCustomEventDOMErrorDOMExceptionDOMImplementationDOMParserDOMTokenListDocumentDocumentFragmentDocumentTypeElementEventEventTargetHTMLCollectionMutationObserverMutationRecordNamedNodeMapNodeNodeIteratorNodeListProcessingInstructionQuotaExceededErrorRangeShadowRootStaticRangeTreeWalkerXMLDocumentXPathEvaluatorXPathExpressionXPathResultXSLTProcessorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |