我试图制作一个可拖动的div。我可以很好地操纵数据集,但我无法调整偏移量。我怀疑this
关键字的某些内容让我感到沮丧,但我不确定是什么。为什么我可以读取this
但不访问函数的属性?
$(".flyout")
.mousedown(function() {
this.dataset.moving = "true"; //works as intended
})
.mouseup(function() {
this.dataset.moving = "false"; //works as intended
})
.mousemove(function(e) {
var moving = this.dataset.moving; //works as intended
if (moving == "true") {
this.offset({ top: e.pageY, left: e.pageX }); //this.offset is not a function.
}
});