Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在jquery拖动事件中检测悬停_Javascript_Jquery_Drag And Drop - Fatal编程技术网

Javascript 在jquery拖动事件中检测悬停

Javascript 在jquery拖动事件中检测悬停,javascript,jquery,drag-and-drop,Javascript,Jquery,Drag And Drop,我使用的是jQueryUI拖放效果,当我拖动元素时,我需要执行一段代码来检测元素是否悬停 更新:现场示例: 这是我的拖动代码: <script type="text/javascript"> $(function(){ $('.list-disc').sortable({ connectWith: '.list-disc', drag: function(event, ui){ $(".prof-name

我使用的是jQueryUI拖放效果,当我拖动元素时,我需要执行一段代码来检测元素是否悬停

更新:现场示例:

这是我的拖动代码:

<script type="text/javascript">
   $(function(){
      $('.list-disc').sortable({
         connectWith: '.list-disc',

         drag: function(event, ui){
            $(".prof-name").hover(function(event) {
               var $obj = event.target;
               if (!timeoutId) {
                  timeoutId = window.setTimeout(function() {
                  timeoutId = null;
                  $($obj).next().slideToggle();
                  }, 2000);
               }
            },
            function (event) {
            if (timeoutId) {
               window.clearTimeout(timeoutId);
               timeoutId = null;
            }
            else {
               $(event.target).next().slideToggle();
            }
         });
         },

        start: function (event, ui){
           //SomeCode
        },
        stop: function (event, ui){
          //SomeCode
        }
        })
</script>    
试试这个:

$( ".list-disc").sortable({
  over: function( event, ui ) { // $(this) will be the current hovered element }
});

你能发布一个JSFIDLE演示吗?我们会更容易帮助你wau@Ron当然,更新了codepen live示例。您确定示例正确吗?我在示例中没有看到任何可排序的函数这不是您应该如何使用它。。您应该检查over`if$.prof name==$this'的内部,然后执行您想要的操作,否则它不在该元素上。我还建议您使用console.log$this,并在悬停时查看它所在的元素
$( ".list-disc").sortable({
  over: function( event, ui ) { // $(this) will be the current hovered element }
});