- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Modernizr,并且我从另一个网站复制了我的解决方案,我之前在该网站上使用过它并且没有任何问题。
当我加载页面时,我收到 ReferenceError: $ is not Defined。 (引用$(document).ready(function() {...)
现在我知道我明白了,因为 jquery 没有加载,但我无法弄清楚我在这里缺少什么来阻止 jquery 加载。
我错过了什么?
编辑:取出网址并在此处发布原始代码:
<script src="http://www.domain.com/js/modernizer.custom.js"></script>
<script>
//use the modernizr load to load up external scripts. This will load the scripts asynchronously, but the order listed matters. Although it will load all scripts in parallel, it will execute them in the order listed
Modernizr.load([
{
load: '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'
},
{
// test for media query support, if not load respond.js
test : Modernizr.mq('only all'),
// If not, load the respond.js file
nope : '/js/respond.min.js'
}
]);
</script>
最佳答案
不要使用Modernizer.load
对于 jQuery - .load
函数主要用于加载polyfills和兼容性插件等。
只需在其自己的中独立加载 jQuery <script>
在引用 $
之前标记.
如果您确实想继续使用.load
,您需要将初始 jQuery 相关代码移至 .load
完成回调,这样您就不会尝试调用 jQuery,直到 Modernizr 异步加载它。
关于javascript - 使用 Modernizr,但 $ 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28054505/
Modernizr提供Download Builder可以选择某些测试的工具,并提供该组测试的源代码。生成的输出的顶部是一个返回到该特定构建的 URL。 距离提供一个 URL 似乎并不遥远,我可以在其
我正在试验 Modernizer.load。 我有这个: Modernizr.load([ { load : ['/js/jquery-1.6.1.js', '/js/
我在 Modernizr 网站上看到,Modernizr 3.0 将完全重写 Modernizr。 问题: 我在哪里可以找到新的 Modernizr 解释? V3 会向后兼容吗? 我可以在任何地方找到
IE 和 Microsoft Edge ( Data URI link modernizr - 如何使用 HTML 导入有条件地导入 modernizr?
我希望有条件地导入带有 polymer 的东西。如何构建如下所示的东西。 // I can use geo navigator.geolocation.
我正在尝试在 browserify 项目中要求特定的 Modernizr 测试,但我一定做错了什么。 我使用 deamdify使用 browserify 构建时进行转换。 Modernizr 需要作为
在使用 yep/nope/modernizr.load() 加载资源之前,我需要检查是否支持两项。如何才能做到这一点? 并且在通过两个测试时,不是一个或另一个,而是两个。 一个是我已经添加的自定义测试
这个想法是加载页面/something/index.html 。但是,在我展示它之前,它的依赖项(在这种情况下是 css 和图像)是预加载的。 Modernizr.load({ load: [
我只是在检查 modernizr 类的 css 表达式是如何工作的……正如我在 Google dev 上看到的那样。工具如下: //normal css .box{ width:100px;
我正在尝试在我的页面的特定于页面的 js 文件中加载 excanvas polyfill。此脚本文件插入到我页面上的 body 标记之后。 奇怪的是,如果我使用 在我的 head 标签中,一切正常,
我想这样安装 modernizr: bower install modernizr 一切似乎都很好,但是当我检查 bower_components/modernizr 时,我在任何地方(甚至没有子目录
我正在使用 webpack 来捆绑我的 javascript 文件。 我的 Webpack 配置(使用 gulp 传递给 webpack)如下所示: var webpackConfig = {
我对 RequireJS 和 Modernizr 有疑问。 我希望 Modernizr 资源在头部。以及体内的其他一切。原因是 Modernizr 需要在 DOMContentLoad 之前做一些事情
我知道我可以创建 Modernizr 的自定义构建来检测我关心的功能。但是有没有办法使用与 Bower 一起安装的 Modernizr 来检测特定功能或一组功能(例如 SVG 支持),而不包含整个库?
我正在尝试使用 Modernizr 来检测浏览器是否支持某些音频编解码器,但它似乎没有达到我的预期。 我运行了以下内容 if(Modernizr.audio.mp4){ //Do Somet
我必须使用一些 pollfills 才能让 IE 9 与 enquire.js 很好地配合。当我在不使用 Modernizr 异步加载的情况下加载脚本时,一切都很好,所以我想知道下面的问题出在哪里?我
我试图让我的脚本仅在屏幕尺寸高于特定尺寸(800px)时触发,不仅在加载时触发,而且在屏幕调整大小时触发。 我已将其放入 Modernizr mq 脚本中,但它的触发不一致。有时它会在小屏幕尺寸下触发
我正在使用 Modernizr 运行触摸事件测试,测试似乎运行良好,但仍然是一个只有在测试成功时才会调用的函数。 这是测试: Cluster.prototype.test_touch_event_su
我使用 Modernizr 的加载程序(集成的 yepnope.js)有条件地加载 javascript 代码。这是我的代码: Modernizr.load({ test: Modernizr.geo
我使用的是默认 Modernizr (2.6.2)构建(包含在 head 中)。我在使用 Google Chrome(版本 33.0.1750.152)的 Retina MBPro 笔记本电脑上,当我
我是一名优秀的程序员,十分优秀!