Question: use javascript 1. We want to create a page that allows a user to create boxes randomly within a large container. Each box that is
use javascript
1. We want to create a page that allows a user to create boxes randomly within a large container. Each box that is created within the container should be draggable within the container. The box SHOULD NOT go outside of the container; i.e. if a box is dragged to the edges, it should not go past the edge of the container.
Create HTML that has a div element with a width of 600px, a height of 600px and a black border around it. Create a button element that has an id of createBoxes and a text label of Create Box.
When you click the button, create a div element randomly positioned within the container with a height of 40px and a width of 40px and a border with a color of #00FF00.
These created div elements should be clicked and dragged around the container. You should use the mousemove event rather than the drag/drop events.
When the divs are dragged to the edge of the container, they should stop dragging so that they are not outside of the boxes. I.e., No part of the div elements should end up outside of the main container
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
