欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

jquery实现可拖动DIV自定义保存到数据的实例_jquery

程序员文章站 2022-05-18 13:40:02
...
看到一个不错的jquery插件,可拖动DIV,顺序可保存到数据库的一个实例:这里就以其中PHP实例简单说明一下:

复制代码 代码如下:

//post到后台的数据
if ($_POST) {
$ids = $_POST["ids"];
for ($idx = 0; $idx $id = $ids[$idx];
$ordinal = $idx;
//...
}
return;
}
?>

复制代码 代码如下:











jQuery List DragSort PHP Example



Homepage




Save list order with ajax:






" });

function saveOrder() {
var data = $("#gallery li").map(function() { return $(this).data("itemid"); }).get();
//通过ajax模拟post的方式,post格式形式为:[0, 1, 2, 5, 4, 3, 8, 6, 7]
$.post("example.php", { "ids[]": data });
};