38 lines
910 B
JavaScript
38 lines
910 B
JavaScript
var list = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信", "友善"];
|
|
var body = document.querySelector("body");
|
|
var index = 0;
|
|
body.onclick = function(e) {
|
|
var Xcoord = e.x;
|
|
var Ycoord = e.y;
|
|
var span = document.createElement("span");
|
|
var color = parseInt(Math.random() * 360);
|
|
span.innerText = list[index];
|
|
span.style.position = "fixed";
|
|
span.style.left = `${Xcoord}px`
|
|
span.style.top = `${Ycoord}px`
|
|
span.style.color = `hsl(${color},100%,50%,0.7)`;
|
|
|
|
motion(span, Ycoord)
|
|
|
|
function motion(el, top) {
|
|
setTimeout(function() {
|
|
el.style.top = `${top-100}px `
|
|
}, 300);
|
|
setTimeout(function() {
|
|
body.removeChild(el)
|
|
}, 1300);
|
|
|
|
}
|
|
|
|
|
|
body.appendChild(span)
|
|
|
|
console.log(span);
|
|
index += 1;
|
|
if (index > 11) {
|
|
index = 0
|
|
|
|
}
|
|
|
|
|
|
} |