更新时间:2022-12-07 08:42:46
确保最初隐藏你的警告框。此外,您似乎将JavaScript变量放入HTML中。字符串bag.session.username也可能总是评估为true。也许这个?
Make sure to initially hide your alert box. Also it looks like your putting a JavaScript variable right into your HTML. Also the string bag.session.username may always evaluate to true. Maybe this?
<script type="text/javascript">
$(document).ready(function () {
if (typeof bag.session.username != "undefined") {
$(".alertBox span").text(bag.session.username);
$(".alertBox").show();
}
else {
$(".alertBox").hide();
}
});
</script>