单击并拖动创建一个div [英] Create a div by click and drag
问题描述
我想通过点击和拖动在我的应用程序中创建一个div。点击将启动div创建,而拖动将调整div的大小。
I want to be able to create a div in my application by clicking and dragging. Clicking would initiate the div creation, while dragging would resize the div.
我在几个jquery日历插件中看到类似的功能,我想要能够在我的申请也是。
I have seen similar functionality in several jquery calendar plugins, I want to be able to do it in my application too.
任何人都可以指导我进入正确的方向吗?任何jQuery插件或者我缺少的东西?
Can anyone please guide me into the right direction? Any jQuery plugin or something that I am missing?
感谢您的帮助。
推荐答案
您可以按照以下方案:
当鼠标按钮关闭时,您记录x / y值。当它出现时,您记录新的x / y值。从后者中减去第一个;如果结果不为负,请创建具有这些维度的div。
When the mouse button goes down, you record the x/y values. When it comes up, you record the new x/y values. Subtract the first from the latter; if the result is not negative, create a div with those dimensions.
这篇关于单击并拖动创建一个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!