使用Dreamweaver,是否有机会在关闭标记后立即自动启动Class或ID作为注释?例如,这是原始代码
<section class="container">
<div id="menu">
</div>
</section>
是否可以选择将其转换为
<section class="container">
<div class="row">
</div><!-- end .row -->
</section><!-- end .container -->
提前谢谢。
答案 0 :(得分:2)
我找到了答案here
我认为它应该有效:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
/* Comment Division End Tags script ©2008 John Davenport Scheuer
as first seen in http://www.dynamicdrive.com/forums/
username:jscheuer1 - This notice must remain for legal use
*/
function commentEndTags(){
for (var c, d = document.getElementsByTagName('div'), i = d.length - 1; i > -1; --i)
if(d[i].id || d[i].className){
c = document.createComment(' end div' + (d[i].id? ' id:' + d[i].id : '') + (d[i].className? ' class:' + d[i].className : '') + ' ');
if(d[i].nextSibling)
d[i].parentNode.insertBefore(c, d[i].nextSibling);
else
d[i].parentNode.appendChild(c);
}
var commented = document.createElement('textarea');
with (commented){
rows = 20;
cols = 80;
wrap = 'off';
with (style){
position = 'absolute';
zIndex = 10000;
top = '0px';
left = '0px';
overflow = 'auto';
}
}
commented.value = document.body.innerHTML;
document.body.appendChild(commented);
}
if(window.addEventListener)
window.addEventListener('load', commentEndTags, false);
else if(window.attachEvent)
window.attachEvent('onload', commentEndTags);
</script>
</head>
<body>
<div id="rwf_OuterContainer">
<div id="rwf_MainContainer">
</div>
</div>
<div id="bob" class="otherContainer">
</div>
</body>
</html>
请注意,这在DW运行时无效,只能在渲染页面上使用。
但至于个人经验,我会推荐Emmet插件。
以下是example如何在标记结束后使用它自动注释。