我的jquery.js適用於使用JavaScript,但不適用於jQuery。 jQuery文件不起作用。jQuery不能使用Express
下面是我的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);
});
});
這是一個不是co的社區網站mmercial。不要提供資金。 – marekful
*「任何幫助我解決這個問題的人,我會給你5美元」 - 所以如果有200人回答,你準備支付1000美元?無論如何,你似乎沒有在你的頁面上包含jQuery庫。 – nnnnnn
還有另一個在express中使用jQuery的庫。請參閱https://github.com/cheeriojs/cheerio –