我正在为我的可排序列表使用接收事件,我需要该事件能够在从可拖动元素中拖动元素时更改元素的其中一个子元素的样式。这是一个简化的示例:
<ul id="sortable">
<li>element1<div class="child"></div></li>
<li>element2<div class="child"></div></li>
<ul>
<ul id="draggable">
<li>element3<div class="child"></div></li>
<li>element4<div class="child"></div></li>
<ul>
使用 JS:
$('#sortable').sortable(
{
//extra stuff excluded
receive: function(e, ui)
{
//how do I use ui to get the child element "child"?
//also I need to be able to style the current li element
}
}
);
$('#draggable').draggable(
{
connectToSortable: '#sortable'
}
);
*已解决的问题:Frédéric Hamidi 在下面发布了答案,但简而言之,答案是在 sortable 上使用停止事件而不是接收事件。