我正在尝试检查用户提交的内容是否包含正确的信息。我通过将输入的上下文添加到变量 [code] 来执行此操作,然后尝试 if else catch 以查看它是否与我想要的匹配。[强] 变量。
但是,它似乎不起作用,任何人都可以对此有所了解吗?请看下面的代码。
$(document).ready(function() {
$('#button-bold').click(function() {
var code = jQuery("textarea#bold-code").val();
var $pass = "Congratulations, You have entered this correctly";
var $fail = "Oops, Look again, can you see where you have gone wrong?"
var $strong = "<strong>Recreate this preview Exactly</strong>";
if (code == strong) {
alert(pass);
$('#bold-output').append(code)
}else {
alert(fail);
}
});
});
谢谢大家。