[英]How to move parent div when hover to child image using jquery sortable?
I have two text box with an equalsign image. 我有两个带有等号图像的文本框。 I need when the user hovers over equalsing image then he can move the div otherwise he can't move it.
当用户将鼠标悬停在均等图像上时,我可以移动div,否则不能移动它。
I mean the user can move the div with the help of equal sign. 我的意思是用户可以在等号的帮助下移动div。 Would you help me?
你能帮我吗?
$( function() { $( "#sortable1" ).sortable({}); $( "#sortable1" ).disableSelection(); } );
.border-bg{ border: 1px solid #333; background-color: #f8f8f8; width: 250px; } #sortable1 img, #sortable2 img{ width: 25px; height: 25px; vertical-align: middle; cursor:move; }
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <div id="sortable1"> <div class="border-bg" > <div class="" > <img src="http://icons.veryicon.com/ico/System/Icons8%20Metro%20Style/Mathematic%20Equal%20sign2.ico"> <label>name</label> <input type="text" name="name" placeholder="name"> </div> </div> <div class="border-bg"> <div class="" > <img src="http://icons.veryicon.com/ico/System/Icons8%20Metro%20Style/Mathematic%20Equal%20sign2.ico"> <label>Email</label> <input type="email" name="email" placeholder="email"> </div> </div> </div>
you can pass handle option for sortable with selector to be used like below or use some class name for images and use it. 您可以传递句柄选项以使用选择器进行可排序,如下所示,也可以为图像使用一些类名并使用它。
$( "#sortable1" ).sortable({
handle: "img"
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.