<tfoot id='SChoM'></tfoot>
      <bdo id='SChoM'></bdo><ul id='SChoM'></ul>
    1. <i id='SChoM'><tr id='SChoM'><dt id='SChoM'><q id='SChoM'><span id='SChoM'><b id='SChoM'><form id='SChoM'><ins id='SChoM'></ins><ul id='SChoM'></ul><sub id='SChoM'></sub></form><legend id='SChoM'></legend><bdo id='SChoM'><pre id='SChoM'><center id='SChoM'></center></pre></bdo></b><th id='SChoM'></th></span></q></dt></tr></i><div id='SChoM'><tfoot id='SChoM'></tfoot><dl id='SChoM'><fieldset id='SChoM'></fieldset></dl></div>
    2. <small id='SChoM'></small><noframes id='SChoM'>

    3. <legend id='SChoM'><style id='SChoM'><dir id='SChoM'><q id='SChoM'></q></dir></style></legend>

      :hover 拖放到元素上

      :hover sticks to element on drag and drop(:hover 拖放到元素上)
      <i id='h0iKv'><tr id='h0iKv'><dt id='h0iKv'><q id='h0iKv'><span id='h0iKv'><b id='h0iKv'><form id='h0iKv'><ins id='h0iKv'></ins><ul id='h0iKv'></ul><sub id='h0iKv'></sub></form><legend id='h0iKv'></legend><bdo id='h0iKv'><pre id='h0iKv'><center id='h0iKv'></center></pre></bdo></b><th id='h0iKv'></th></span></q></dt></tr></i><div id='h0iKv'><tfoot id='h0iKv'></tfoot><dl id='h0iKv'><fieldset id='h0iKv'></fieldset></dl></div>

        <small id='h0iKv'></small><noframes id='h0iKv'>

        <tfoot id='h0iKv'></tfoot>
          <tbody id='h0iKv'></tbody>

          <bdo id='h0iKv'></bdo><ul id='h0iKv'></ul>

        • <legend id='h0iKv'><style id='h0iKv'><dir id='h0iKv'><q id='h0iKv'></q></dir></style></legend>

                本文介绍了:hover 拖放到元素上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I have simple ol-li construction and want to add drag'n'drop to it. Additionaly I want to highlight hover item and dragover item in different colors. But it is an unusual bug in WebKit.

                1. Capture last item.
                2. Drag it to the top.
                3. Drop it to the first item.

                And last element capture the hover pseudoclass! Why? How can I prevent it?

                This is an example:

                http://jsfiddle.net/zFk2V/3/

                var lis = document.querySelectorAll("li"),
                    ol = document.querySelector("ol"),
                    dragged = false,
                    dragover = false;
                ol.addEventListener("drop", function(event) {
                    ol.insertBefore(dragged,dragover);
                    this.classList.remove("insistent");
                }, false);
                for (var i=0, n = lis.length; i < n; i++) {
                    lis[i].addEventListener("dragstart", function(event) {
                        dragged = this;
                        ol.classList.add("insistent");
                    }, false);
                    lis[i].addEventListener("dragover", function(event) {
                        if (dragover) {
                            dragover.classList.remove("dragover");
                        }
                        event.preventDefault();
                        dragover = this;
                        this.classList.add("dragover");
                    }, false);
                }
                

                解决方案

                You can simply add an .onmouseover and an .onmouseout function and add/remove a class called hovered instead of using CSS's :hover. Here is the updated jsFiddle

                Javascript to add (inside for loop)

                lis[i].onmouseover = function() {
                    // Adds the 'hovered' class
                    this.className = this.className + " hovered";
                }
                lis[i].onmouseout = function() {
                    // Removes the 'hovered' class
                    this.className = this.className.split(' ').filter(function(v) {
                        return v!='hovered'
                    }).join(' ');
                }
                

                CSS

                .hovered {
                    background: #fc9;
                }
                

                Side note: I might add an id to the ol like id='dragableList' and change the line var lis = document.querySelectorAll("li") to var lis = document.getElementById('dragableList').querySelectorAll("li") just in case you have another list somewhere in your project later on. Here is the jsFiddle with that included

                这篇关于:hover 拖放到元素上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                Ordinals in words javascript(javascript中的序数)

                  <small id='u3Brf'></small><noframes id='u3Brf'>

                    1. <tfoot id='u3Brf'></tfoot>
                        <tbody id='u3Brf'></tbody>
                      <legend id='u3Brf'><style id='u3Brf'><dir id='u3Brf'><q id='u3Brf'></q></dir></style></legend>
                        <i id='u3Brf'><tr id='u3Brf'><dt id='u3Brf'><q id='u3Brf'><span id='u3Brf'><b id='u3Brf'><form id='u3Brf'><ins id='u3Brf'></ins><ul id='u3Brf'></ul><sub id='u3Brf'></sub></form><legend id='u3Brf'></legend><bdo id='u3Brf'><pre id='u3Brf'><center id='u3Brf'></center></pre></bdo></b><th id='u3Brf'></th></span></q></dt></tr></i><div id='u3Brf'><tfoot id='u3Brf'></tfoot><dl id='u3Brf'><fieldset id='u3Brf'></fieldset></dl></div>

                          <bdo id='u3Brf'></bdo><ul id='u3Brf'></ul>