用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‘);
})
})

})

用jQuery将页面制成简单画板

原文地址:https://www.cnblogs.com/huanxijiuhao/p/9215472.html

为您推荐

发表评论

电子邮件地址不会被公开。 必填项已用*标注