jquery - 使用jquery和modernizr插入html

标签 jquery html debugging modernizr

对 Modernizr 和 jQuery 很陌生,但根据我见过的示例,我认为这会起作用。 Modernizr 和 jQuery 脚本已加载,位于页面下方:

<div id="demo></div>
<script>
(function() {
    if (Modernizr.mq('only screen and (min-width: 500px)')) {
        $('div.demo').html('test');
    }
});
</script>

那么我到底错过了什么?谢谢。

最佳答案

我认为你需要:

$('div#demo')

#表示ID。

.表示一个类。

关于jquery - 使用jquery和modernizr插入html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16132549/

相关文章:

java - 如何将 boolean 变量作为 ModelAttribute 对象的字段发送到服务器端?

jquery - DataTables - 为最后一列添加 colspan 时不工作

javascript - 这段 jQuery 代码我做错了什么?

html - Angular css 形状

jQuery-turbolinks - link_to 确认 : pops up several times times in Rails

css - HTML5 : ng-show/hg-hide violating the grid position?

html - 换行而不打断单词

javascript - 如何调试这个 Testcafe 案例?

c# - 使用 BeginInvoke 调试异常

java - 是什么让 SSMS 中的 CyanogenMod 允许堆转储,无论其调试标志如何?