我在根据单击提交按钮来组合事件时遇到了一些麻烦。Chat.send()
我的目标是在用户按下“发送”按钮时使用页面顶部字段中的用户输入来运行该功能。重申一下,我想将文本栏中的字符串传递给Chat.send()
用户单击发送按钮时。我对此很陌生,正在寻找一个小方向。我对它进行了破解,但它根本不起作用..
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://chatbuilder.hackreactor.com/ChatBuilder.js"></script>
</head>
<body>
<script>
Chat.guide.start();
</script>
<h2>Borken Chat</h2>
<input class="draft" type="text"/> <button class="send" disabled>send</button>
<ul class="messages">
<script>
var Chat_Messages=[];
function fetchNew() {
var PrintChat=function(Chat_Messages){
var y=Chat_Messages.length;
for(i=0;i<y;i++){
Chat.display(Chat_Messages[i]);
}
}
Chat.fetch(PrintChat);
}
setInterval(fetchNew,3000);
/*
*$('#send').click(function(){
var Input=<input class="draft" type="text">
Chat.send(Input)
}) **This was my attempt. I was trying to use the "send" button to trigger an event that calls Chat.fetch on a variable that I was trying to define as the user input*/
</script>
</ul>
</body>
</html>