Reputation:
Just wanted to resize and drag an image but resizable
is not working.
Where is the issue ? I could not solve it.
$(function() {
$('#wrapper').draggable();
$('#image').resizable();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<div id="wrapper" style="display:inline-block">
<img id="image" src="http://www.google.com.br/images/srpr/logo3w.png" />
</div>
Upvotes: 6
Views: 1689
Reputation: 76557
You aren't currently referencing the jQuery UI Library (both CSS and Javascript), which is the actual library that handles the draggable()
and resizable()
functions :
<div id="wrapper" style="display:inline-block">
<img id="image" src="http://www.google.com.br/images/srpr/logo3w.png" />
</div>
<!-- jQuery UI CSS Reference -->
<link href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<!-- jQuery Reference (required for jQuery UI) -->
<script src="https://code.jquery.com/jquery-1.11.3.js"></script>
<!-- jQuery UI Reference -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<!-- Your Script Here -->
<script>
$(function() {
$('#wrapper').draggable();
$('#image').resizable();
});
</script>
You can see a working example of this here and demonstrated below :
Upvotes: 1
Reputation: 33218
draggable
and resizable
are part of jquery-ui so you have to include it:
$(function() {
$('#wrapper').draggable();
$('#image').resizable();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<div id="wrapper" style="display:inline-block">
<img id="image" src="http://www.google.com.br/images/srpr/logo3w.png" />
</div>
Upvotes: 5