jQuery UI Sortable refreshPositions() 方法
jQuery UI是一种基于网络的技术,由各种GUI部件、视觉效果和主题组成。这些功能可以使用jQuery JavaScript库来实现。jQuery UI是为网页建立UI界面的最佳工具。它也可以用来建立高度互动的网络应用程序,或者可以用来轻松地添加小工具。
在这篇文章中,我们将使用jQuery UI Sortable refreshPositions() 方法来刷新可排序的项目。它规定了所有可分类项目的重新加载,并允许新的项目被识别。
语法:
$( ".selector" ).sortable( "refreshPositions" );
参数:该方法不接受任何参数。
返回值:该方法返回一个对象值。
CDN链接:下面是一些jQuery Mobile脚本,你的项目将需要这些脚本,所以要把它们添加到你的项目中。
<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”>
<script src= “https://code.jquery.com/jquery-1.12.4.js”></script>
<script src= “https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script>
例子 。这个例子描述了jQuery UI Sortable refreshPositions()方法的用途。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet"
href=
"https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src=
"https://code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<style>
#sortable {
list-style-type: none;
}
#sortable li {
margin: 5px 5px 5px 5px;
padding: 1px;
width: 250px;
height: 40px;
font-size: 25px;
color: black;
background-color: green;
}
</style>
<script>
(function() {
("#sortable").sortable({
stop: function(ev, ui) {
var children = ('#sortable')
.sortable('refreshPositions')
.children();
alert('Positions: ');
.each(children, function() {
alert($(this).attr('id'));
});
}
});
});
</script>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h4>jQuery UI Sortable refreshPositions() Method</h4>
<div class = "list_data">
<div class = "list_data1">
<ul id = "sortable">
<li class = "ui-state-default"
id = "Geeks1">Geeks1</li>
<li class = "ui-state-default"
id = "Geeks2">Geeks2</li>
<li class = "ui-state-default"
id = "Geeks3">Geeks3</li>
</ul>
</div>
</div>
</center>
</body>
</html>
输出: