If I do “jquery sortable” on a contenteditable ite

2019-03-18 01:34发布

Strangely this is broken only in Firefox and Opera (IE, Chrome and Safari works as it should).

Any suggestions for a quick fix?

<html>
<head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot; type="text/javascript"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js&quot; type="text/javascript"></script>
  <script>
  $(document).ready(function(){
      $('#sortable').sortable();
  });
  </script>
</head>
<body>
  <span id="sortable">
    <p contenteditable="true">One apple</p>
    <p>Two pears</p>
    <p>Three oranges</p>
  </span>
</body>
</html>

7条回答
时光不老,我们不散
2楼-- · 2019-03-18 02:34

specify a classname for all editable content, then capture all the onmousedown events using this:

$('.classname').each ( function(){
    $(this)[0].onmousedown = function() {
        this.focus();
    };
});
查看更多
登录 后发表回答