javascript - jQuery选择日期时间属性大于04-01-2020的时间元素
问题描述
我的页面有几个 <time datetime='...'> ... </time> 元素。我想使用 jQuery 来选择那些具有 datetime 属性授予者的元素,然后是今天。我不高兴地使用了以下脚本。谢谢你的帮助。
$('time[new Date(datetime) > new Date.now()]').click(function(e){...})
解决方案
您可以使用filter()来实现,例如:
$("time").filter(function() {
return Date.parse($(this).attr("datetime")) > new Date();
})
推荐阅读
- c# - VS 2019:构建 Docker 映像在运行 dotnet restore 时抛出异常
- typescript - 为什么我们需要在使用打字稿选择元素之前添加元素参数
- html - lightgallery 在 django 中不起作用,它显示黑屏
- c# - 异步上传大文件而不释放它
- javascript - 超时时角度更改 img src
- r - 按生成 NA 的日期合并数据帧
- python - 使用 openpyxl 导入 Excel 文件时出现问题(文件路径问题)
- python - 如何使用 CV 运行程序进行人脸检测?
- r - 使用 glmer 将数据拟合到偏移的 Gamma 分布
- ruby-on-rails - 安装rails时构建websocket-driver时出错