1 1.点哪 哪出15*15的圆型div 添加元素 2 <script> 3 var divArr=[]; 4 document.addEventListener('click',function (e) { 5 var newDiv=document.createElement('div'); 6 var color='#' + (Math.random().toString(16)).substr(-6); 7 newDiv.style.width='50px'; 8 newDiv.style.height='50px'; 9 newDiv.style.border='1px solid color'; 10 newDiv.style.borderRadius='50%'; 11 newDiv.style.position='absolute'; 12 newDiv.style.top=e.clientY-25/2+'px'; 13 newDiv.style.left=e.clientX-25/2+'px'; 14 newDiv.style.background=color; 15 document.body.appendChild(newDiv); 16 divArr.push(newDiv); 17 for (var i = 0; i < divArr.length; i++) { 18 divArr[i].style.backgroundColor = "#" + ((Math.random() * 111).toString(16)).substr(3, 6); 19 } 20 }) 21 </script>