笔记——document.createElement创建添加属性

动态添加div中,需要进行添加id,class,style等属性

做下记录

[javascript]  view plain  copy
  1. var div = document.createElement('div');  
  2. div.id = 'mask_div1';  
  3. div.className = 'mask';  
  4. div.appendChild(document.createTextNode("test"));  
  5. div.style.position = "absolute";  
  6. div.style.left =  '20px';  
  7. div.style.top =  '20px';  
  8. div.style.overflow = "hidden";  
  9. div.style.zIndex = "9999";  
  10. div.style.opacity = 0.3; 

猜你喜欢

转载自blog.csdn.net/qq_41813695/article/details/80340201