Method na XML DOM surroundContents()

Tafiyar da Amfani

Method na surroundContents() yana samun yauwa da yauwarin yankin da ake kawo a cikin yauwa

Syntax:

surroundContents(newParent)

Parameter

Parameter Description
newParent za a zama abin da zai zama iyali na yauwa na yankin na yauwa

yinwa

Method na zai yinwa a kwarin a yinwa da kooda DOMException kiwon baiwatai RangeException kiwon baiwa:

DOMException.HIERARCHY_REQUEST_ERR

Yana ce yauwarin na farko na nisanin yankin yauwa kuma yana iya samun yara, kuma yana iya samun newParent kwarin yanuwa ko na yauwarin newParent Yana ce gida ce yauwarin yankin

DOMException.NO_MODIFICATION_ALLOWED_ERR

The ancestor node of the current range's boundary points is read-only, and insertion operations are not allowed.

DOMException.WRONG_DOCUMENT_ERR

newParent and its range is created with a different Document object.

RangeException.BAD_BOUNDARYPOINTS_ERR

The current range partially selects a node (other than a Text node), so it cannot enclose this area of the document.

RangeException.INVALID_NODE_TYPE_ERR

newParent is a Document, DocumentFragment, DocumentType, Attr, Entity, or Notation node.

Description

This method will redefine the parent node of the current range to newParent, and then newParent inserted at the beginning position of the document range in the document. For example, to put a section of the document into a <div> or <span> element, you can use this method.

If newParent If it is already part of the document, it will first be removed from the document, and its child nodes will also be discarded. When this method returns, the range will be newParent The position before is the start point,newParent The position after is the end point.