Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Drag and Drop: Show Class On Drop

What I'm trying to do: Drag content into drop zone when content is dropped show hidden class.

I've called the class I want to hide until drop: .hideme in the code snippet below:

    <script>

function allowDrop(ev) {
    ev.preventDefault();
}

function dragStart(ev) {
    ev.dataTransfer.setData("text", ev.target.id);
}

function dragDrop(ev) {
    ev.preventDefault();
    var data = ev.dataTransfer.getData("text");
    ev.target.appendChild(document.getElementById(data));
}
</script>

<div class="draggable-container"></div>
<div class="div1"
    ondrop="dragDrop(event)"
    ondragover="allowDrop(event)">
<div id="drag1"
    draggable="true"
    ondragstart="dragStart(event)"
    width="220"
    height="70">
   <p>Dragable Content</p> 
   <div class="hideme">Hide This Until Drop</div>
</div>
</div>

<div class="div1" id="dropzone"
    ondrop="dragDrop(event)"
    ondragover="allowDrop(event)">
</div>

I have tried googling this in every way my little brain can think of and I'm coming up with nothing. I'm not sure if it's just so obvious to anyone who knows how to write javascript that there aren't tutorials for it or if it's WAY more complicated than it seems? I'm desperate help!

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda