<div id="div1">bar</div>
JQuery的
function comment(element){
element.wrap(function() {
return '<!--' + this.outerHTML + '"-->';
});
}
comment($('#div1'));
我想使用JQuery取消注释HTML,请帮助
答案 0 :(得分:0)
即使您的问题看起来很奇怪这是我的Js答案,它使用我正确的HTML格式。
<div class="comment">My div to comment<div>
<script>window.onload = function() {
var commentDivs = getElementByClassName("comment")
commentDivs.forEach((div) => {
div.outerHTML = "<!--" + div.outerHTML + "-->"
}
}
</script>