码迷,mamicode.com
首页 > Web开发 > 详细

用jQuery将页面制成简单画板

时间:2018-06-22 21:50:03      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:back   height   color   rand   ack   use   idt   pagex   mat   

$(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将页面制成简单画板

标签:back   height   color   rand   ack   use   idt   pagex   mat   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!