I have a main div with three inner divs labeled 1, 2, and 3 as shown below:
<div id="main">
<div style="height:30px; background-color:yellow;" class="bnr">Banner</div>
<div style="height:30px; background-color:yellow;" class="bnr">Banner2</div>
<div style="height:30px; background-color:yellow;" class="bnr">Banner3</div>
</div>
My goal is to add a dragged
<div class="other"></div>
after any div with the class 'bnr' when dropped on a 'placeholder'. This means that when hovering over any of these three divs, it should show a 'placeholder' in between them. For instance, if I hover over <div> 1
, a placeholder <div>
appears between <div> 1
and <div> 2
.
The layout for the placeholder is:
<div style="height:30px; background-color:light-yellow;" class="placeholder"></div>
After attempting some solutions, I realized that I need to utilize the '.droppable' function's properties 'over', 'out', and 'drop' instead of using jQuery's .mouseenter and .mouseleave functions.
$(".other").draggable({
helper: 'clone'
});
$('.placeholder').droppable({
over: function (event, ui) {
},
out: function (event, ui) {
},
drop: function (event, ui) {
}
});
How can I successfully drop onto the 'placeholder' div?
Since the placeholder is created dynamically after mouseover, the '.on' function needs to be utilized. Can you guide me on how to incorporate '.droppable' with '.on' or suggest an alternative solution?