1
JavaScript Drag n drop! hälp!
Postat av SweGrix den 23 September 2014, 23:52
0 kommentarer · 294 träffar
Vad är felet? När man drar t.ex. en bild över rutan så ska den gå från grå till svart men det vill den fan inte.
HTML
<html>
<head>
<meta charset="utf-8">
<title>Drag & Drop Uploading</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<div id="uploads"></div>
<div class="dropzone" id="dropzone">Drop Files here to upload</div>
<script>
(function() {
var dropzone = document.getElementById('dropzone');
dropzone.ondragover = function() {
this.classname = 'dropzone dragover';
return false;
}
dropzone.ondragleave = function() {
this.classname = 'dropzone';
return false;
}
}());
</script>
</body>
</html>
CSS
body
{
font-family: sans-serif;
}
.dropzone
{
width: 300px;
height: 300px;
border:2px dashed #ccc;
color: #ccc;
line-height: 300px;
text-align: center;
}
.dropzone.dragover
{
border-color: #000;
color: #000;
}
HTML
<html>
<head>
<meta charset="utf-8">
<title>Drag & Drop Uploading</title>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<div id="uploads"></div>
<div class="dropzone" id="dropzone">Drop Files here to upload</div>
<script>
(function() {
var dropzone = document.getElementById('dropzone');
dropzone.ondragover = function() {
this.classname = 'dropzone dragover';
return false;
}
dropzone.ondragleave = function() {
this.classname = 'dropzone';
return false;
}
}());
</script>
</body>
</html>
CSS
body
{
font-family: sans-serif;
}
.dropzone
{
width: 300px;
height: 300px;
border:2px dashed #ccc;
color: #ccc;
line-height: 300px;
text-align: center;
}
.dropzone.dragover
{
border-color: #000;
color: #000;
}