用jQuery将页面制成简单画板

$(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');
})
})

})

posted on 2018-06-22 21:02  假装200斤身体里灵魂很有趣  阅读(175)  评论(0编辑  收藏  举报

导航