我在查找有关此问题的所有以前的帖子时遇到了麻烦。
我的网站上加载了一个div,我想根据天/月将其删除
因此,我想在每年9月7日至1月4日之间的任何日期删除div#example。所以我不想将其限制为一年,因为这将是每年一次。
这样对吗 ?
if (/Sept 7|Oct|Nov|Dec|Jan 4/.test(new Date())) {
} else {
$("#example").remove();
}
尝试使用RegExp
/-09-0[7-9]|-09-[1-3]|-10-|-11-|-12-|-01-0[1-4]-/
,.test()
以new Date().toJSON()
作为参数,如果结果new Date().toJSON()
回报true
,呼叫.remove()
上#example
元
if (/-09-0[7-9]|-09-[1-3]|-10-|-11-|-12-|-01-0[1-4]-/.test(new Date().toJSON())) {
$("#example").remove()
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句