Javascript > HTML 输出纯文本

标签 javascript jquery html ubuntu

我有一个小问题,但我自己找不到问题:/

所以我有一小部分代码:

<html>
<head>
  <title>Chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box;}
body { font:13px Helvetica, Arial; }
form { background: #000; padding:3px; position:fixed; bottom:0; width:100%;}
form input { border:0; padding: 10px; width: 90%; margin-right: .5%;}
form button { width:9%; background: rgb(130,224,255); border: none; padding:10px;}
#messages { list-style-type: none; margin:0; padding:0;}
#messages li { padding: 5px 10px;}
#messages li:nth-child(odd) { background: #eee; }
</style>

</head>
<body>

<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off"/><button>Send</button>
</form>

<script src="https://cdn.socket.io/socket.io-1.4.5.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script
<script>
var socket = io();
$('form').submit(function(){
    socket.emit('chat message', $('#m').val());
    $('#m').val('');
    return false;
});
socket.on('chat message', function(msg){
    $('#messages').append($('<li>').text(msg));
});
</script>
</body>
</html>

但是,<script></script>之间的部分其中 var 套接字 = io(); 开始以纯文本形式吐出...

enter image description here

我找不到问题,也许你们中有人知道......

谢谢!

最佳答案

您缺少>

<script src="http://code.jquery.com/jquery-1.11.1.js"></script

应该是:

<script src="http://code.jquery.com/jquery-1.11.1.js"></script>

关于Javascript > HTML 输出纯文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35095812/

相关文章:

javascript - 数组中的嵌套对象 - 对象解构 es6

jQuery - 选择列表中最后一个 LI 的每个 UL

php mysql pdo postdata htm - 无法将数据正确获取到 mysql 错误

javascript - 将结果转化为变量

javascript - 显示选定点的 Highcharts 工具提示

html - oEmbed API 端点和 URL 方案与链接标签相比有何意义?

javascript - 如何使用 JS 正则表达式将文本 block 中的每个最后一个字母变为粗体

javascript - 使用 SuiteScript 2.0 创建发票时如何传递日期以进行交易

javascript - 由于脚本过多,网站字体和 JavaScript 运行缓慢

javascript - 在 Javascript 中检测已提交的表单