Can you use jquery to add comments dynamically to code?

前端 未结 9 1461
无人共我
无人共我 2021-01-18 05:20

I tried:


but it didn

9条回答
  •  再見小時候
    2021-01-18 05:53

    You're mixing two completely unrelated concepts there: HTML and the DOM.

    HTML is a textual means of describing content, which — like code — has a means of commenting things out. The DOM is the resulting object model in the browser.

    Once the HTML has been read and parsed and the DOM has been created, the HTML is discarded and unnecessary. Adding HTML comments to things won't change them, and in fact doesn't make sense (although it's easy to see how you thought it would, don't get the wrong idea).

    Once you have the DOM, to hide an element without removing it, use hide. To remove it entirely, use remove.

    Live examples of both: http://jsbin.com/araju

提交回复
热议问题