【发布时间】:2014-11-12 08:39:51
【问题描述】:
我已经尝试了 3 种解决方案,但都没有成功。
我想用评论标签包裹我的侧边栏。
第一个解决方案:
$("#sidebar").wrap("<!--googleoff: index--><!--googleon: index>");
第二种解决方案:
来自这个帖子:jQuery comment/uncomment <!--element-->
function comment(element){
element.wrap(function() {
alert(this.outerHTML);
return '<!--googleoff: index-->'+this.outerHTML+'"<!--googleon: index>';
});
}
comment($('#sidebar'));
第三种解决方案:
$('#sidebar').prepend("<!--googleoff: index-->");
$('#sidebar').append("<!--googleon: index>");
我想要的结果:
<!--googleoff: index--> //start comment tags
<div id="sidebar"></div>
<!--googleon: index> // tags
【问题讨论】: