$(function () {
$(document).on(‘mousedown‘, function (e) {
var e = e || window.event;
$(document).on(‘mousemove‘, function (e) {
var e = e || window.event;
var x = e.pageX;
var y = e.pageY;
$(‘<div></div>‘).css({
‘position‘: ‘absolute‘,
‘width‘: ‘5px‘,
‘height‘:‘5px‘,
‘borderRadius‘:‘50%‘,
‘left‘: x, ‘top‘: y })
.appendTo(‘body‘); $(‘div‘).css(‘background‘,
function Color() {
var r = parseInt(Math.random() * 256);
var g = parseInt(Math.random() * 256);
var b = parseInt(Math.random() * 256);
return "rgb(" + r + ‘,‘ + g + ‘,‘ + b + ")";
});
})
$(document).on(‘mouseup‘, function () {
$(document).off(‘mousemove‘).off(‘mouseup‘);
})
})
})
原文地址:https://www.cnblogs.com/huanxijiuhao/p/9215472.html
时间: 2024-10-02 23:22:33