【发布时间】:2019-07-14 08:35:38
【问题描述】:
我正在努力在 html 中创建可调整大小的 DIV,并在网上找到了一些代码作为参考。
在 chrome 上运行 HTML 源代码时,resizable 功能不起作用,我只能看到没有功能的纯文本。但是,代码在 JSFiddle 上运行良好。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Resizable - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<style>
#resizable { width: 150px; height: 150px; padding: 0.5em; }
#resizable h3 { text-align: center; margin: 0; }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#resizable" ).resizable();
} );
</script>
</head>
<body>
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Resizable</h3>
</div>
</body>
</html>
这是我正在使用的确切代码。任何想法为什么它不能在 chrome 上正常运行?
【问题讨论】:
-
它在你的 sn-p 中工作得很好。
-
hrefs of<link>不正确?也可以看看 Chrome 中的 DevTools,它可能已经报错了。 -
检查是否有任何关于加载jquery的控制台错误,如果有将jquery导入替换为cdn链接
https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js -
危险:jQuery 1.12.4 已经过时了。它不会获得安全更新。升级到受支持的 jQuery 版本。
标签: javascript