【发布时间】:2014-03-25 06:56:03
【问题描述】:
我为我正在开发的一个小型聊天系统提供了这个功能。当用户在一些文本前键入“shout”时(例如:“shout hello!”)。我只想要“你好!”输出(其余的应该被忽略)。当我只有一个命令时,这很好用。但现在我有“喊”和“信息”。我尝试使用下面的代码做一些事情,但它似乎不起作用:
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。 -
错字,对不起@MikeW,应该改正。