Make comment tags universal across browsers_CSS/HTML
May 16, 2016 pm 12:11 PMUnder IE, the code located under this tag will not be displayed on the page, which is very useful for hiding some HTML code.
However, this tag is invalid under non-IE browsers; you can test the following code under IE and FF respectively to know the effect.
<script type="text/javascript">
alert(document.getElementById("CnLei").innerHTML);
</script>
Solution:
Define comment {display:none;} in CSS to make it universal across browsers.
comment {display:none;}
</style>
<comment id="CnLei"> Test: Hide content </comment>
<script type="text/javascript" >
alert(document.getElementById("CnLei").innerHTML);
</script>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Adding Box Shadows to WordPress Blocks and Elements

Create a JavaScript Contact Form With the Smart Forms Framework

Create an Inline Text Editor With the contentEditable Attribute

Demystifying Screen Readers: Accessible Forms & Best Practices

Making Your First Custom Svelte Transition

Comparing the 5 Best PHP Form Builders (And 3 Free Scripts)

File Upload With Multer in Node.js and Express
