【发布时间】:2017-12-24 02:50:56
【问题描述】:
我的 jquery.js 适用于使用 JavaScript,但不适用于 jQuery。 jQuery 文件不起作用。
下面是我的 app.js
var express = require('express')
var app = express();
app.set('view engine', 'ejs')
app.get('/', function(req, res){
res.sendfile(__dirname +'/views/index.html');
})
app.get('/about', function(req, res){
res.send('this is the about page');
})
app.get('/roster', function(req, res){
res.send('this is the roster page');
})
app.get('/contact', function(req, res){
res.send('this is the conact page');
})
app.use(express.static('public'));
app.listen(3000);
下面是我的 index.html
<head>
<script type="text/javascript" src="/js/jquery.js"></script>
<link href="/css/index.css" rel="stylesheet" type="text/css" />
</head>
<p>hi<p>
<h1><a href="/contact">contact</a></h1>
<body>
<div id="red"></div>
<div id="blue"></div>
<div id="yellow"></div>
<div id="green"></div>
</body>
下面是我的 jQuery.js。我知道所有的路由都正确,因为我运行了一个警报 JavaScript 并且它工作正常。
$(document).ready(function() {
$('div').mouseenter(function() {
$(this).animate({
height: '+=10px'
});
});
$('div').mouseleave(function() {
$(this).animate({
height: '-=10px'
});
});
$('div').click(function() {
$(this).toggle(1000);
});
});
【问题讨论】:
-
这是一个非商业的社区网站。不要给钱。
-
“任何帮助我解决这个问题的人,我都会向你开 5 美元” - 如果有 200 人回答,你准备好支付 1000 美元了吗?无论如何,您的页面上似乎没有包含 jQuery 库。
-
还有另一个库用于在 express 中使用 jQuery。参考这里github.com/cheeriojs/cheerio
-
"jquery 文件不工作。"关于堆栈溢出,这里不是一个好问题。请解释预期的行为是什么,观察到的行为是什么以及您需要帮助的确切问题是什么。此外,请解释您自己采取了哪些调试步骤以及从中学到了什么。此外,我们需要知道浏览器控制台中显示的错误。
-
对于 5 美元的报价,我深表歉意。我会确保我在这里发布的下一个问题会更专业。顺便说一句,添加 JQuery 库来表达是什么意思?你的意思是仅仅包括
标签: javascript jquery node.js express