"how to drag and drop" Code Answer's

You're definitely familiar with the best coding language Html that developers use to develop their projects and they get all their queries like "how to drag and drop" answered properly. Developers are finding an appropriate answer about how to drag and drop related to the Html coding language. By visiting this online portal developers get answers concerning Html codes question like how to drag and drop. Enter your desired code related query in the search bar and get every piece of information about Html code related question on how to drag and drop. 

drag and drop html

By Different DuckDifferent Duck on Jun 09, 2021
<!DOCTYPE HTML>
<html>
   <head>
   <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>
   </head>
<body>

   <div id="box" ondrop="drop(event)"
   ondragover="allowDrop(event)"
   style="border:1px solid black; 
   width:200px; height:200px"></div>

   <img id="image" src="sample.jpg" draggable="true"
   ondragstart="drag(event)" width="150" height="50" alt="" />

</body>
</html>

Add Comment

1

drag and drop

By Code_BreakerCode_Breaker on Sep 14, 2020
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DRAG_AND_DROP</title>
    <style>
  	body{
    background-color: aquamarine;
}
.whiteBox{
    height: 250px;
    width: 250px;
    background-color: rgb(55, 238, 245);
    margin: 10px;
    display: inline-block;
    border: 2px solid red;
}
.imgBox{

    display: flex;
    background-image: url("image.jpg");
    height: 230px;
    width: 230px;
    position: relative;
    top: 10px;
    margin:0 auto;
    cursor: pointer;

}
.imgBox1{

    display: flex;
    background-image: url("image.jpg");
    height: 230px;
    width: 230px;
    position: relative;
    top: 10px;
    margin:0 auto;
    cursor: pointer;

}
.hold{
    border: 2px dashed rgb(118, 182, 0);
}
.hide{
    display: none;
}
.dragenter{
    background: rgb(221, 115, 96);
    border-color: green;
    border-style: groove;
}
  	</style>
</head>
<body>
    <div class="whiteBox">
        <div class="imgBox" draggable="true"></div>
    </div>
    <div class="whiteBox"></div>
    <div class="whiteBox"></div>
    <div class="whiteBox"></div>
    <script>
  	console.log("D&D");

let imgBox = document.querySelector(".imgBox");
let whiteBoxes = document.querySelectorAll(".whiteBox");

imgBox.addEventListener("dragstart", (e) => {
  console.log("DRAG STARTED");
  e.target.className += " hold";
  setTimeout(() => {
    e.target.className += " hide";
  }, 0);
});
imgBox.addEventListener("dragend", (e) => {
  console.log("DRAG ENDED");
  e.target.className = "imgBox";
});

for (whiteBox of whiteBoxes) {
  whiteBox.addEventListener("dragover", (e) => {
    e.preventDefault();
    // console.log("gj")
  });
  whiteBox.addEventListener("dragenter", (e) => {
    e.target.className += " dragenter";
  });
  whiteBox.addEventListener("dragleave", (e) => {
    e.target.className = "whiteBox";
  });
  whiteBox.addEventListener("drop", (e) => {
    let answer= confirm("Do you really want to move it")
    console.log(answer)
    if(answer){
        e.target.append(imgBox)}
        else{
            e.target.className = "whiteBox";
       
    }
  });
}

  	</script>
</body>
</html>

Add Comment

2

how to drag and drop

By OzzzyOzzzy on May 28, 2021
Actions action = new Actions(driver);
action.clickAndHold(driver.findElement(By.id("item")))
.moveToElement(driver.findElement(By.id("destination")))
.release().build().perform();

Add Comment

0

All those coders who are working on the Html based application and are stuck on how to drag and drop can get a collection of related answers to their query. Programmers need to enter their query on how to drag and drop related to Html code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to drag and drop for the programmers working on Html code while coding their module. Coders are also allowed to rectify already present answers of how to drag and drop while working on the Html language code. Developers can add up suggestions if they deem fit any other answer relating to "how to drag and drop". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to drag and drop resolved professionally and stay updated to the latest Html updates. 

Html answers related to "how to drag and drop"

View All Html queries

Html queries related to "how to drag and drop"

Browse Other Code Languages

CodeProZone