javascript - jquery UI 可拖动性和可调整大小功能不起作用

标签 javascript jquery html css jquery-ui

当我在 jsfiddle 上使用外部资源时,这个可拖动性代码可以正常工作。

但是,通过脚本和样式标签包含 jquery 和 jquery ui 文件并不会使我的 div 可拖动和/或调整大小。

这太烦人了。我已经尝试这个很久了。

Here's my code

HTML:

   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type="text/javascript"></script>
      <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css">
      <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>

  <div id="outer" style="background-color: #3C3C3C; width: 300px; height: 300px;">
           <div id="object1" class="draggable resizable">
           </div>
  </div>

CSS:

  .draggable.resizable
  {
      position: relative; 
      display: -moz-inline-stack;
      display: inline-block;
      vertical-align: top;
      zoom: 1;
      *display: inline;   

      cursor: hand; 
      cursor: pointer;
      border: 1px solid #E0E0E0;
      z-index: 1;
  }


  .ui-resizable-handle  {
      background: #E0E0E0;
      width: 9px;
      height: 9px;
      z-index: 0;
  }


  .ui-resizable-se
  {
      right: -5px;
      bottom: -5px;
  }

  .ui-resizable-ne
  {
      right: -5px;
      bottom: -5px;
  }



  #object1 {
    background-color: yellow;
    position: absolute;
    left: 10px;
    top: 20px;
    width:30px;
    height: 50px;

  }

JS:

  $('.draggable').draggable({
    containment: '#outer'
  });

  $('.resizable').resizable({
      //aspectRatio: true,
        containment:'#outer'
      , handles: 'ne, se, sw, nw'
  });

最佳答案

正如用户 R Lam 指出的,如果您在网络浏览器中打开控制台,您应该会看到以下错误。

Mixed Content: The page at 'https://fiddle.jshell.net/akashdmukherjee/wj41wLcx/1/show/' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'. This request has been blocked; the content must be served over HTTPS. (index):117 Mixed Content: The page at 'https://fiddle.jshell.net/akashdmukherjee/wj41wLcx/1/show/' was loaded over HTTPS, but requested an insecure stylesheet 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css'. This request has been blocked; the content must be served over HTTPS. (index):1 Mixed Content: The page at 'https://fiddle.jshell.net/akashdmukherjee/wj41wLcx/1/show/' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js'. This request has been blocked; the content must be served over HTTPS. (index):97 Uncaught ReferenceError: $ is not defined

可以通过将 http://替换为//来修复

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js" type="text/javascript"></script>

The following JS Fiddle works

关于javascript - jquery UI 可拖动性和可调整大小功能不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34652917/

相关文章:

jquery - 为 Accordion 菜单设置动画时选项卡会弹跳

javascript - 如何选择设置为显示 :none, 的第 n 个类型选择器以将其更改为显示 :block when a btn is clicked?

javascript - 这个 fetch 调用问题

javascript - 使用 rxjs 延迟和迭代对象

javascript - 如何使用 JQuery 或 JavaScript 删除表格中的所有链接?

javascript - 更改可变文本颜色

javascript - session 存储在获取时是否有延迟?

javascript - 在 eq() 中使用变量

javascript - rails 5 : Select2 Gem not working

html - IE11 中的边框折叠和 colspan