我刚刚在Windows上安装了node.js. 我有这个不运行的简单代码:
我得到:错误:听EADDRINUSE
是否有配置文件告诉node.js监听特定端口?
问题是我已经在端口80上监听Apache了.
编辑:
var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
console.log("Request: " + req.method + " to " + req.url);
res.writeHead(200, "OK");
res.write("<h1>Hello</h1>Node.js is working");
res.end();
}).listen(5454);
console.log("Ready on port 5454");
Run Code Online (Sandbox Code Playgroud) 我在一本jQuery书中看到了这个:
$(elems).mouseenter(function(e) {
$(this).css("opacity", 0.5);
}).mouseout(function(e) {
$(this).css("opacity", 1.0);
})
Run Code Online (Sandbox Code Playgroud)
我删除了大部分代码以便于阅读,然后得到了这个:
$(elems).mouseenter(function(e)).mouseout(function(e))
Run Code Online (Sandbox Code Playgroud)
看起来一般情况下你可以做到这一点?:
$(elems).mouseenter(function(e)).mouseout(function(e)).mouseSOMETHING1(function(e))
Run Code Online (Sandbox Code Playgroud)
使用的另一个词.连接函数?
如果我打破这段代码说:
$(elems).mouseenter(function(e) {$(this).css("opacity", 0.5);});
$(elems).mouseout(function(e) {$(this).css("opacity", 1.0);});
Run Code Online (Sandbox Code Playgroud)
这是一样的吗?
谢谢,吉姆
我有以下javascript代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script>
function Person(first, last) {
this.first = first;
this.last = last;
}
Person.prototype.toString = function() {
return this.first + this.last;
}
var person = new Person("John", "Dough");
alert(person); // same result since alert calls toString()
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
问题是为什么alert(person)显示"JohnDough"?对我来说,alert(person) 不应该显示任何东西.