WrapInnerHtml wraps an HTML structure, matched by the given selector, around the content of element in the set of matched elements. The matched child is cloned before being inserted into the document. It returns the original set of elements.
(htmlStr string)
| 522 | // |
| 523 | // It returns the original set of elements. |
| 524 | func (s *Selection) WrapInnerHtml(htmlStr string) *Selection { |
| 525 | nodesMap := make(map[string][]*html.Node) |
| 526 | for _, context := range s.Nodes { |
| 527 | nodes, found := nodesMap[nodeName(context)] |
| 528 | if !found { |
| 529 | nodes = parseHtmlWithContext(htmlStr, context) |
| 530 | nodesMap[nodeName(context)] = nodes |
| 531 | } |
| 532 | newSingleSelection(context, s.document).wrapInnerNodes(cloneNodes(nodes)...) |
| 533 | } |
| 534 | return s |
| 535 | } |
| 536 | |
| 537 | // WrapInnerNode wraps an HTML structure, matched by the given selector, around |
| 538 | // the content of element in the set of matched elements. The matched child is |