Noname1231
Recurring Income Master
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
400 XP
In this tutorial, we are going to learn how to the image into the box using javascript. This is a simple project that you can use in your website or system.
DIRECTIONS
HTML CODE
JAVASCRIPT CODE
CSS CODE
Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
DIRECTIONS
HTML CODE
- <div
id
=
"container"
>
- <p
>
Drag Image into the squares using HTML5</
p
>
- <div
id
=
"left"
>
- <div
id
=
"div1"
ondrop=
"drop(event)"
ondragover=
"allowDrop(event)"
></
div
>
- <br
>
- <div
id
=
"div1"
ondrop=
"drop(event)"
ondragover=
"allowDrop(event)"
></
div
>
- <br
>
- </
div
>
- <img
id
=
"drag1"
src
=
"drag.png"
draggable=
"true"
ondragstart=
"drag(event)"
width
=
"150"
>
- <div
id
=
"right"
>
- <div
id
=
"div1"
ondrop=
"drop(event)"
ondragover=
"allowDrop(event)"
></
div
>
- <br
>
- <div
id
=
"div1"
ondrop=
"drop(event)"
ondragover=
"allowDrop(event)"
></
div
>
- <br
>
- </
div
>
- </
div
>
JAVASCRIPT CODE
- <
script>
- function
allowDrop(
ev)
{
- ev.preventDefault
(
)
;
- }
- function
drag(
ev)
{
- ev.dataTransfer
.setData
(
"text"
,
ev.target
.id
)
;
- }
- function
drop(
ev)
{
- ev.preventDefault
(
)
;
- var
data =
ev.dataTransfer
.getData
(
"text"
)
;
- ev.target
.appendChild
(
document.getElementById
(
data)
)
;
- }
- </
script>
CSS CODE
- <style>
- #div1
{
width
:
150px
;
height
:
150px
;
padding
:
10px
;
border
:
1px
solid
#aaaaaa
;
}
- #left
- {
- border
:
1px
solid
#aaaa
;
- width
:
200px
;
- float
:
left
- }
- #right
- {
- border
:
1px
solid
#aaaa
;
- width
:
200px
;
- float
:
right
;
- }
- #container
- {
- width
:
580px
;
- margin
:
auto
;
- }
- p
- {
- font-size
:
25px
;
- text-align
:
center
;
- }
- </style>
Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.