<! DOCTYPE html>
<meta charset= "UTF-8" >
<title> Point, which out of the 15*15 round div</title>
<style type= "Text/css" >
html,body{
height:100%;
margin:0;
padding:0;
}
. Yuan {
width:16px;
height:16px;
border-radius:50%;
Position:absolute;
}
</style>
<body>
<script>
/**
* Dot which out of the 15*15 round Div
*/
Document.body.addEventListener (' click ', Function (e) {
var div = document.createelement (' div '); Creating DIV elements
var className = Document.createattribute (' class ');//Create Class attribute
Classname.value = ' yuan ';//property assignment
Div.style.left = e.clientx-16/2 + ' px ';
Div.style.top = e.clienty-16/2 + ' px ';
Div.setattributenode (className);//Set attribute node
Div.style.backgroundColor = ' # ' + parseint (0XFFFFFF * math.random ()). toString (16);//random background color
Document.body.appendChild (div);//add element div to body
})
</script>
</body>
JS little Exercise--click where in the page, where the div appears (circle)