我想在使用sortable时选择当前元素

时间:2011-06-17 18:09:16

标签: jquery jquery-ui

//我想要在新位置拖动元素 //根据新位置更改所选选项 //检查之前的项目和拖动后的项目 //您抓取的项目采用正确的选定选项                                                            1                         2                         3                                                                                      12                         3                                                                                      1                         2                         3                                    

当我使用此代码时

$(document).ready(function(){
      $("#contain").sortable({
          stop: function(event, ui){
               // i want to take the value of the current
              currItem=$(this).find('option:selected').text();
              alert(currentItem); // this display all item and i want the current element only 


          }
      });

1 个答案:

答案 0 :(得分:0)

如果要拖动当前项目,请使用

$(document).ready(function(){
$("#contain").sortable({
    stop: function(event, ui){
         // i want to take the value of the current
        var currItem = ui.item;
        alert(currentItem); // this display all item and i want the current element only 
    }
});