【发布时间】:2014-01-06 23:45:44
【问题描述】:
我尝试了以下代码来测试 Modernizr.mq,我想为 yep 加载一个 js 代码。
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>S123</title>
<link rel="stylesheet" href="css/s.css" />
<script src="js/modernizr.com.js"></script>
</head>
<body>
<script>
Modernizr.load({
test: Modernizr.mq,
yep : alert("hello, beautiful"),
nope: alert("very poor choice of words"),
});
</script>
</body>
</html>
但它同时给了我yep 和nope 警报。
我不知道为什么,测试代码(如下)运行良好
if (Modernizr.mq("only screen and (min-width:480px)")) {
alert("hello");
};
谁能告诉我我做错了什么?
【问题讨论】: