سؤال

<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
  <li>6</li>
</ul>


$('ul').sortable();

Let's say, I'm moving around li #6. If I place it between #1 and #2, I need to get a hold of li #1. If I place it between #3 and #4, I need to get a hold of li #3. How would I do that?

هل كانت مفيدة؟

المحلول

You would select this item with prev() in the stop callback:

$('ul').sortable({
    stop: function(e, ui) {
        alert(ui.item.prev().html());
    }
});

See this fiddle: http://jsfiddle.net/TprfC/1/

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top