jquery 可排序警报此列表 id

标签 jquery user-interface jquery-ui-sortable

确实需要帮助

我正在使用 jquery 可排序。

我希望从正在拖动的列表元素中获取 id。

“并非全部都关闭”

这是一个示例 http://jsfiddle.net/isimpledesign/85LdV/1/

这会返回一个数组,但我需要它返回正在拖动的元素的 id,以便我可以将其传递给 php 文件。

有人可以帮我解决这个问题吗???

最佳答案

只是为了澄清乍得的答案 -

$(function() {
    $("#sortable").sortable({
        update: function(event, ui) {
            // i need to get the class text that is being dragged i.e
            var order = $(this).sortable("serialize");
            alert(order); 
            /*
             No need to bind any other events, ui.item is the dragged
             item in 'update' too and we only want to capture the id when the sort
             has changed presumably
            */
            alert(ui.item.attr('id'));
            /*
             No need for subscripting, ui.item is a jquery object so 
             we can just call attr() on it to get the ID
            */
        }
    });
});

关于jquery 可排序警报此列表 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5899361/

相关文章:

Javascript/jQuery/JSON/localStorage 游戏,无法按数字排序排名表

php - Jquery 在提交后显示一次

java - 根据要求动态切换布局管理器是一个好习惯吗?

java - 运行时无法将 JButton 添加到 JPanel

javascript - ng-repeat 不打印任何内容

javascript - 如何使用 jquery 获取所有 css 的设置?

java - 从构造函数构建 GUI。 [设计决策]

javascript - 拖动项目时触发的单击事件 (Firefox)

javascript - Jquery Ui 可排序项目选项仅选择第一项

jquery - 防止第一个元素之前的可排序下降