1
我有一个我正在使用的小型聊天系统的这个功能。当用户在前面加上一些文字(例如:“shout hello!”)时,输入“shout”。我只想要“你好!”输出(其余的应该被忽略)。当我只有一个命令时,这很好。但现在我有“喊”&“消息”。我试着用下面的代码做一些事情,但它似乎没有工作:替换几个输入值
function checkValue() {
var value = document.getElementById("thisinput").value;
// output text without "message" in front
if (value == "message") {
$('#output').html(value.replace('message', ''));
}
// output text without "shout" in front
else if (value == "shout") {
$('#output').html(value.replace('shout', ''));
}
// output nothing
}
谢谢!
您将测试'shout',但是用'setimg'。 – 2014-03-24 22:44:37
错字,抱歉@MikeW,应该修复。 – WalkOfLife