<div class="aa">demo</div>
<script type="text/javascript">
function fnWrapAll(s,sWrap){
var oFrag = document.createDocumentFragment(),o = document.querySelectorAll(s),oTemp;
o[0].insertAdjacentHTML('beforeBegin',sWrap);
oTemp = o[0].previousSibling;
[].forEach.call(o,function(o){
oFrag.appendChild(o);
});
oTemp.appendChild(oFrag);
}
fnWrapAll('.aa','<div id="wrap"></div>');
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…