How do I change the css of an element on a drop event in interact.js?

This is my code, I’ve tried using setAttribute and don’t understand why it doesn’t work. I’ve also tried using .transform with the same result.
setAttribute is located in the ondrop event function.

        // Require a 75% element overlap for a drop to be possible
        overlap: 0.75,
        // listen for drop related events:
        ondropactivate: function (event) {
            // add active dropzone feedback
        ondragenter: function (event) {
            var draggableElement = event.relatedTarget
            var dropzoneElement =
            // feedback the possibility of a drop
        ondragleave: function (event) {
            // remove the drop feedback style
        ondrop: function (event) {
            event.relatedTarget.setAttribute('resize-drag', 'width:100px')
            event.relatedTarget.setAttribute('resize-drag', 'height:100px')
        ondropdeactivate: function (event) {
            // remove active dropzone feedback

>Solution :

Just for debugging purposes, can you try adding a classList ? That way you’ll see the class appended

Create a custom class to change something visible such as the background as example. That might help you.

Also, try to provide a sandbox if you can, it’s easier to help that way!

Leave a Reply