博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DOM commend
阅读量:7012 次
发布时间:2019-06-28

本文共 381 字,大约阅读时间需要 1 分钟。

var comment = document.createComment("commend content");

var elem = document.getElementById("someElement");
elem.appendChild(comment);

 

类型                                 nodeName       nodeType

COMMENT_NODE              #comment   8 (commend)

 

comment 可以用来定位,因为 textNode 不能出现在table内,可以用 comment替代。

使用场景,比如我们模板,需要 repeator 控件时,之后能动态插入的话,我们可以使用 comment 来定位。 

angular ng-repeat 就是用了这个。

转载于:https://www.cnblogs.com/keatkeat/p/3916617.html

你可能感兴趣的文章