troubleshooting Question

drag elements

Avatar of codelevel
codelevel asked on
JavaScriptjQueryWeb Languages and Standards
6 Comments1 Solution86 ViewsLast Modified:
i want to drag and drop the elements based on the class.
please help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
function allowDrop(ev) {
function drag(ev) {
function drop(ev) {
    var data = ev.dataTransfer.getData("text");;
<div style="float:left;width:200px;border:1px solid blue;margin:0 0 20px 0"> 
<img src="" alt="1" class="male" draggable="true" ondragstart="drag(event)"/>
<img src="" alt="2" class="male" draggable="true" ondragstart="drag(event)" /> 
<img src="" alt="3" class="female" draggable="true" ondragstart="drag(event)"/> 
<img src="" alt="4" class="female" draggable="true" ondragstart="drag(event)" /> 
<img src="" alt="5" class="male" draggable="true" ondragstart="drag(event)" /> 
<img src="" alt="6" class="female" draggable="true" ondragstart="drag(event)"/> 
<div style="float:left;width:200px;border:1px solid blue;margin:0 10px 0 0;clear:both" ondrop="drop(event)" ondragover="allowDrop(event)">
<div style="float:left;width:200px;border:1px solid red" ondrop="drop(event)" ondragover="allowDrop(event)">
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros