Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尝试通过 Chrome 控制台更改 jQuery 中 div 元素的 CSS 并获得以下响应:
$('#first-block').css('color','green') TypeError: Object #<HTMLDivElement> has no method 'css'
但是,当我打电话时
$('#first-block')
控制台返回 div 及其内容
我正在使用带有 MongoDB 的 Express.js,利用 Express 缓存中间件。
看来您没有正确加载 jQuery。确保您已在 haed 部分中加载了 jQuery,并且您的代码以适当的方式包装,例如
<script type="text/javascript"> jQuery(document).ready(function ($) { $('#first-block').css('color','green'); }); </script>