html - 关闭标签后 DreamWeaver 自动注释

标签 html dreamweaver

使用 Dreamweaver,是否有机会在关闭标记后立即自动获取起始类或 ID 作为注释?例如这是原始代码

<section class="container">
   <div id="menu">

   </div>
</section>

是否可以选择将其转换为

<section class="container">
   <div class="row">

   </div><!-- end .row -->
</section><!-- end .container -->

提前谢谢你。

最佳答案

我找到了答案 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 Runtime 中不起作用,它只能在呈现的页面上起作用。

但就个人经验而言,我会推荐Emmet插件。

这是一个 example标签关闭后如何使用它自动评论。

关于html - 关闭标签后 DreamWeaver 自动注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26921755/

相关文章:

javascript - 弹出窗口中的溢出滚动条不起作用( Bootstrap )

css - 添加其他 div 时,标题 div 会更改其位置

html - 从 Photoshop 或 InDesign 导出 HTML 和 CSS

php - 如何让sql语句搜索百分号?

php - PHP 中的正则表达式 (preg_match) 模式

Javascript onclick 函数调用问题 : won't pass a string

CSS 所有正文内容居中

javascript - 多个按钮仅在代码中打开最近的模态

Dreamweaver : Solution? CSS 保存错误

php - 在插入数据库之前检查MySQL中的记录