Skip to content
Related Articles

Related Articles Drag & Drop hoverclass Option

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 20 Nov, 2020

This Drag & Drop hoverclass Option is used create a active hoverclass where you can drag a drag-able element to a drop area. In that drop area, the element will be placed. This is a name of a CSS class which will be added to an element while the droppable option is active.


Droppables.add('element', {hoverclass: 'cssClass'});

Example: Below example illustrate the Drag & Drop hoverclass Option.

<!DOCTYPE html>
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript">
        window.onload = function () {
                "img")).each(function (item) {
                    new Draggable(
                        item, { revert: true, ghosting: true });
                "droparea", {
                    hoverclass: "hoverActive",
                onDrop: moveItem
            // Set drop area default non cleared.
            $("droparea").cleared = false;
        function moveItem(draggable, droparea) {
            if (!droparea.cleared) {
                droparea.innerHTML = "";
                droparea.cleared = true;
    <style type="text/css">
        #draggables {
            width: 550px;
            height: 73px;
        #droparea {
            float: left;
            width: 550px;
            height: 73px;
            border: 2px solid gray;
            text-align: center;
            font-size: 16px;
            padding: 12px;
        <h1 style="color: green;">GeeksforGeeks</h1>
        <p>A Computer Science Portal for Geeks</p>
    <strong> Drag & Drop hoverclass Option
    <div id="draggables">
        <img src="gfg.png" />
    <div id="droparea">
        Drag the Image and Drop Your Image in this area


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!