动态添加div中,需要进行添加id,class,style等属性
var div = document.createElement('div');
div.id = 'mask_div1';
div.className = 'mask';
div.innerText = 'abc'; //给div赋文本值
div.appendChild(document.createTextNode("test"));
div.style.position = "absolute";
div.style.left = '20px';
div.style.top = '20px';
div.style.overflow = "hidden";
div.style.zIndex = "9999";
div.style.opacity = 0.3;
document.body.appendChild(div);