当我尝试这样做时
<option disabled = "disabled" <!-- Used to disable any particular option -->
selected = "selected" <!-- Used to pre-select any particular option -->
label = "string" <!-- Used to provide a short version of the content in the option -->
value = "value"> <!-- The actual value that will be send to the server. If omitted the content between the option opening and closing tags will be send. -->
Option 1
</option>
我试图在元素的开放标签内注释属性和值。 但是,这不起作用,因为浏览器(在IE9、FF4.01、GG11、AF5和Opera11上测试)会将disabled="disabled"后面的所有内容视为注释或内容。HTML注释是否允许在元素的开放标签内?
<noscript class="comment">comment</noscript>
,它没有<!-- -->
的限制,然后在文档解析之前,让JavaScript将其outerHTML设置为空字符串。noscript是首选,因为它是除了脚本以外唯一一个标准标签,足够无意义,使得这种做法有意义。 - Dmytro