Edit this page


Returns the index of specified item. Filtered items are excluded from the collection.

Important: While user drags to sort the original item is hidden and the placeholder is appended to the Sortable collection. This is why jQuery's index method might return incorrect results. When the developer wants to find the index of a given item it is recommended to use widget's indexOf method.


element jQuery

jQuery object which represents the sortable element.


Number the index of specified item.

Example - working with indexOf method

<div id="sortable">
    <h4>Sortable List</h4>

        filter: ">div",
        move: function(e) {
            //NOTE: the heading element will be excluded from the
            //collection as it does not match the filter

            //shows the original position of the item
            console.log("index of item", this.indexOf(e.item));
            //shows the position where item will be moved to
            console.log("index of placeholder", this.indexOf(this.placeholder));
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article