日期:2014-05-16 浏览次数:20538 次
<ui class="selector">
<li class="P">标题<li>
<li class="S">子内容<li>
<li class="S"><li>
<li class="P"><li>
<li class="S"><li>
<li class="S"><li>
</ui>
$('.selector').sortable();?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<style type="text/css">
#sortable{list-style-type: none; margin: 0; padding: 0; width: 60%; }
#sortable li{margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }
#sortable li span{position: absolute; margin-left: -1.3em; }
</style>
</head>
<body>
<ui id="sortable">
<li class="ui-state-default P">标题1</li>
<li class="ui-state-default S">1</li>
<li class="ui-state-default S">2</li>
<li class="ui-state-default P">标题2</li>
<li class="ui-state-default S">3</li>
<li class="ui-state-default S">4</li>
</ui>
</body>
<script type="text/javascript">
$(document).ready(function() {
$('#sortable').sortable({
placeholder: 'place',
change: function(e, ui) {
var first = $('#sortable li').eq(0).hasClass('place');
var is;
if(first) {
is = ui.item.hasClass('S');
if(is) {
return false;
}
}
}
});
});
</script>
</html>