问题
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