jquery - 升级到 Bootstrap 4、jQuery 3.3.1 后 jQuery .show() /.hide() 无法正常工作
问题描述
所以我们有一些像这样的代码
function handleDayClick(date)
{
if (date.local() < startDate || date.local() >= endDate) {
$("#dayClickMsg").show();
return;
}
$('#dayClickMsg').hide();
//do other stuff
}
和一些 HTML:
<div id="dayClickMsg" hidden style="color:seagreen; float:right">
Clicked day not in range.
</div>
但升级后,该功能似乎无法正常工作。在 .show() 上设置断点告诉我正在正确获取元素,但 .show() 方法调用不起作用。同样, .hide() 也不起作用。
编辑,控制台错误:
sign-error-icon.png:1 Failed to load resource: the server responded with a status of 404 ()
help-icon.png:1 Failed to load resource: the server responded with a status of 404 ()
popper:37 Uncaught SyntaxError: Unexpected token export
sign-error-icon.png:1 Failed to load resource: the server responded with a status of 404 ()
help-icon.png:1 Failed to load resource: the server responded with a status of 404 ()
解决方案
尝试使用属性 in 代替
function handleDayClick(date)
{
if (date.local() < startDate || date.local() >= endDate) {
$("#dayClickMsg").prop('hidden', false);
return;
}
$('#dayClickMsg').prop('hidden', true);
//do other stuff
}
推荐阅读
- django - Django - 将数据从视图传输到表单
- scala - Scala Spark 应用程序没有以正确的状态退出
- firebase - 如果我的“患者”firestore 集合中有 10,000 个文档,firesbasefiretore.collection'patients'.snapshots 会收取 10,000 次阅读的费用吗?
- python-3.x - Telethon 客户端使用一段时间后无法连接
- python - 这个递归函数是否返回了基本情况?
- java - Java SDK 在 Mac M1 上报告错误的架构
- python - 在 Django 管理界面中使用不同的小数分隔符进行前端验证
- java - 配置多个消息属性
- r - 在 R 中使用 if_else 从两个不同的变量创建一个变量
- python - 检查列表的每个字典中的参数值是否是顺序的