首页 > 其他分享 >document.createComment All In One

document.createComment All In One

时间:2023-07-12 23:44:38浏览次数:37  
标签:comment el createComment https document Comment

document.createComment All In One

document.createComment

document.createComment("auth")
<!--auth-->

image

MDN

XML / HTML

const docu = new DOMParser().parseFromString("<xml></xml>", "application/xml");
const comment = docu.createComment("This is a not-so-secret comment in your document");

docu.querySelector("xml").appendChild(comment);

console.log(new XMLSerializer().serializeToString(docu));
// <xml><!--This is a not-so-secret comment in your document--></xml>

image

https://developer.mozilla.org/en-US/docs/Web/API/Document/createComment

Comment

let comment = new Comment("Test");

console.log(`comment =`, comment)
// comment = <!--Test-->

image

https://mdn1.moz.one/en-US/docs/Web/API/Comment/Comment?language=en-US

https://developer.mozilla.org/en-US/docs/Web/API/Document/Comment

https://developer.mozilla.org/en-US/docs/Web/API/Comment/Comment

https://dom.spec.whatwg.org/#ref-for-dom-comment-comment①

demos

const removeElement = (el) => {
    // 在绑定元素上存储父级元素
    el._parentNode = el.parentNode
    // 在绑定元素上存储一个注释节点
    el._placeholderNode = document.createComment("auth")
    // 使用注释节点来占位
    el.parentNode?.replaceChild(el._placeholderNode, el)
}

https://juejin.cn/post/7209648356530896953

(

标签:comment,el,createComment,https,document,Comment
From: https://www.cnblogs.com/xgqfrms/p/17549188.html

相关文章

  • Qt QJsonDocument以及与QJsonArray、QJsonObject、QJsonValue的关联
    0、说明QJsonDocument类提供了read/writeJSON文档的方法。用QJsonDocument::fromJson()方法,可以从将一个JSON文件(或者QByteArray数据)转换为QJsonDocument,用QJsonDocument::toJson()则能起到相反的用法。在此过程中的语法解析是很高效的,并且可以将JSON转换为Qt使用的二......
  • 将document输出为字符串
    //获取整个文档对象constdoc=document.implementation.createDocument(null,'html',null);doc.documentElement.innerHTML=document.documentElement.innerHTML;//创建一个XML序列化器constserializer=newXMLSerializer();//将文档对象序列化为字符串const......
  • [GPT] 用 document.querySelector('.xxx') 选择下级的第二个 div 要怎么写
     要选择类名为.xxx的元素下的第二个子<div>元素,可以将querySelectorAll()方法与CSS选择器一起使用。 以下是一个示例:constsecondChildDiv=document.querySelectorAll('.xxx>div')[1];在本例中,document.querySelectorAll('.xxx>div')选择类名为.xxx的元素下的所有直......
  • 使用 ABAP 调用 Adobe Document Service 生成 PDF 文档
    我以前在SAP成都研究院BYDForm开发团队工作过5年,负责BYDBO输出成PDF的功能开发。AdobeDocumentService(ADS)是SAPNetWeaverASJava堆栈的一部分,提供了用于创建和处理PDF文件的功能。在ABAP系统中,可以通过调用ADS服务来生成和处理PDF文档。这种集成使得ABAP开发人员能......
  • autosys document
    http://support.ca.com/phpdocs/0/common/impcd/r11/troubleshooting/doc/autsys_diag_tips_110607.pdf autsys_diag_tips_110607.pdf http://writetrends.files.wordpress.com/2009/09/autosys-edk2uaj45cie.pdfUnicenterAutoSysJobManagementTableofContentsIntrodu......
  • [代码]创建XDocument对象(LINQ to XML)
    LINQtoXML中的XDocument是用来表示内存中的XML文档的。同样可以使用函数构造功能来创建此对象。此示例代码主要用来演示如何创建一个通用的XML文档。示例代码代码中创建的XDocument对象,包含了2个注释(XComment),1个处理指令(XProcessingInstrucation),1个根元素及其若干子元素,也为......
  • [oeasy]python0069_帮助手册_pydoc_manual_document
    帮助手册回忆上次内容 上次了解了注释注释是为了让程序更可读注释不会影响程序运行速度 注释分为两种单行的以#开头不能是字符串当中的# 多行的三个"三个'  多行注释还有什么特殊功能么?......
  • 如何处理 SAP Pricing - Document currency missing 的错误消息
    问题当添加一个物料主数据到Quotation行项目时,遇到如下错误消息:Pricing:Documentcurrencymissing查看这条消息的技术明细:发现是如下代码抛出的,因为字段waerk为空:将下图的currency字段维护之后,问题消失:更一般的思路错误消息"SAPPricing-Documentcurrencym......
  • Office Add-ins documentation
    OfficeAdd-insdocumentation-OfficeAdd-ins|MicrosoftLearn Exceladd-intutorial-OfficeAdd-ins|MicrosoftLearn ......
  • SpringBoot集成Swagger报错:Failed to start bean 'documentationPluginsBootstrapper'
    本文章向大家介绍SpringBoot集成Swagger报错:Failedtostartbean'documentationPluginsBootstrapper';,主要包括SpringBoot集成Swagger报错:Failedtostartbean'documentationPluginsBootstrapper';使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需......