gpt4 book ai didi

javascript - 制作一个根据时间改变其行结构的表

转载 作者:行者123 更新时间:2023-12-02 19:33:19 25 4
gpt4 key购买 nike

我正在尝试制作一个时间表,该表将根据当前时间删除某些行。

示例;

(默认表)

1st ride: 1.15

2nd ride: 1.45

3rd ride: 2.42

假设它是 1.16,那么它会变成这样;

(所需表格)

2nd ride: 1.45

3rd ride: 2.42

如何实现此功能?

最佳答案

使用 HTML 无法做到这一点。

但是,您可以在服务器端执行此操作(通过服务器端脚本,例如 PHPASP perlpython 或您选择的任何其他内容),或在客户端,通过 JavaScript:

例如(为了方便和缩短代码,我在这里使用 JavascriptjQuery library):

<script type="text/javascript">
$(document).ready(function(){

var now = new Date(); // create date object
var h = now.getHours(); // get current hour
var m = now.getMinutes(); // get current minute

// if the time is past 13:15 , hide first row of table with id 'mytable'
if(h>13 || h>12 && m>15) {
$('table#mytable tr:first').hide();
}
});
</script>

关于javascript - 制作一个根据时间改变其行结构的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11261742/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com