Draggable and resizable in JqueryUI for an image is not working?

百般思念 提交于 2019-12-18 17:57:09

问题


I used below code for dragging and resizing the image,

<!DOCTYPE html>
<html>
    <head lang="en">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>

        <script type="text/javascript">
    $(document).ready(function() {

        $( "#img_content" ).draggable().resizable();

    });
    </script>
    </head>
    <body class='default'>       


<div class="demo">
<!--<div id="img_content" class="ui-widget-content">
    <p>Drag me around</p>
</div>-->

<img id="img_content" class="ui-widget-content" src="Tulips.jpg" />

</div>


    </body>
</html>

resizable is working corretly. but dragging the image not working. if i applied for div structure

<div id="img_content" class="ui-widget-content">
        <p>Drag me around</p>
    </div>

its working fine.

How do i implement drag and resize for image tag?


回答1:


You should wrap the image into a div with style="display:inline-block; and then make the div draggable and the image resizable. Working Example




回答2:


The solution I've found was resizing/making dragable a with a background image. I guess that the element is not draggable and resizable. Well, it works for me. Bye.



来源:https://stackoverflow.com/questions/10703450/draggable-and-resizable-in-jqueryui-for-an-image-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!