: - )
我今天早上有这个问题。
我想尝试使用jquery-ui方法调用.sortable()作为列表,但我遇到了这个问题。 当我在console.log中加载页面时,我可以看到: ReferenceError:$未定义。
这里的代码:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Sovversivi e Partigiani - Back-end - Gestione Sovversivi</title>
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<!-- fontawesome -->
<!-- CSS -->
<link rel="stylesheet" href="../CSS/personale.css"/>
<link rel="stylesheet" href="../CSS/jquery-ui.min.css"/>
<link rel="stylesheet" href="../CSS/jquery-ui.structure.min.css">
<link rel="stylesheet" href="../CSS/jquery-ui.theme.min.css">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=EB+Garamond" rel="stylesheet">
</head>
这是列表(带引导程序4)
<div class="row" id="contenutoDaOrdinare">
<ul class="list-group" id="sortable">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
在身体的最后:
<script type="text/javascript">
$( function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
} );
</script>
<!-- Libreria Jquery Bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="../JS/getusers.js"></script>
<script src="../JS/jquery-ui.js"></script>
</body>
我想在html中对列表进行排序。 你能帮助我吗?非常感谢!
答案 0 :(得分:1)
您需要在加载jQuery库后移动该内联脚本,因为它依赖于jQuery UI。
<!-- Libreria Jquery Bootstrap -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="../JS/getusers.js"></script>
<script src="../JS/jquery-ui.js"></script>
<script type="text/javascript">
$( function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
} );
</script>