I want to create a horizontal menu with draggable items along the x axis. Using jQuery 2.1.4 and jQuery UI 1.12.1.
Somehow the code works within the simulator, but not if I run it on a html test webpage and I can not tell the difference.
var nav = $('nav');
nav.draggable({
axis: "x",
containment: 'draggable',
distance: 10
});
nav {
display: flex;
flex-direction: row;
}
nav a {
height: 32px;
padding: 0 10px;
}
.draggable {
width: 300px;
border: 1px solid red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div class="draggable">
<nav>
<a href="">test</a>
<a href="">button</a>
</nav>
</div>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<style>
nav{
display: flex;
flex-direction: row;
}
nav a{
height: 32px;
padding: 0 10px;
}
.draggable{
width: 300px;
border:1px solid red;
}
</style>
<script>
var nav = $('nav');
nav.draggable({
axis: "x",
containment: 'draggable',
distance: 10
});
</script>
</head>
<body>
<div class="draggable" >
<nav>
<a href="">test</a>
<a href="">button</a>
</nav>
</div>
</body>
</html>
Looks like the same thing, why is it not working if I run it within my test.html file?