Create a div by click and drag

我怕爱的太早我们不能终老 提交于 2019-12-24 01:14:54

问题


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.

I have seen similar functionality in several jquery calendar plugins, I want to be able to do it in my application too.

Can anyone please guide me into the right direction? Any jQuery plugin or something that I am missing?

Thanking you for your help.


回答1:


You could following this plan:

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.




回答2:


Don't reinvent the wheel: http://plugins.jquery.com/project/Plugins/category/45



来源:https://stackoverflow.com/questions/1191009/create-a-div-by-click-and-drag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!