【发布时间】:2021-03-04 01:04:01
【问题描述】:
我正在尝试根据今天的日期隐藏 td,以便用户只有在今天的日期匹配时才能看到“立即注册”按钮。
<table class="events-table" >
<thead class="events-thead">
<tr class="events-tr">
<th class="event-time" scope="col">Date/Time</th>
<th class="event-description" scope="col">Event</th>
</tr>
</thead>
<tbody class="events-tbody">
<tr class="events-tr">
<td class="events-td">4 March</td>
<td class="events-link"> Desc. </td>
<td class="cta-td">
<a href="#"> Register Now</a>
</td>
</tr>
</tbody>
</table>
这里是JSFiddle。
我在网站上使用 Wordpress 并尝试使用 Javascript 提出解决方案?
谢谢!
【问题讨论】:
-
你能发布你编码的JS吗? :) StackOverflow 不是代码编写服务。您应该首先自己编写代码。请更新您的问题,以在minimal reproducible example 中显示您迄今为止所做/尝试过的事情。
-
document.querySelector('.events-td').textContent == new Date().toLocaleString('en-gb',{day:'numeric',month:'long'}); -
@Miu 我已经更新了 JSFiddle。
-
@RobG 感谢您的详细回复。我非常感谢,但我实际上是在 Wordpress 上,无法确定日期,因为这些基本上是通过插件发布的事件。
标签: javascript date events show-hide