0

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

例子;

(默认表)

第一次骑行:1.15

第二次骑行:1.45

第三次骑行:2.42

假设它是 1.16,所以它变成了这个;

(所需表)

第二次骑行:1.45

第三次骑行:2.42

我怎样才能实现这个功能?

4

1 回答 1

2

你不能用HTML.

但是,您可以在服务器端(通过服务器端脚本,如PHPASPperlpython或您选择的任何其他脚本)或在客户端通过以下方式执行此操作JavaScript

例如(为了方便和更短的代码,这里我Javascript使用jQuery库):

<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>
于 2012-06-29T12:35:51.003 回答