我正在尝试制作一个时间表,该表将根据当前时间删除某些行。
示例;
(默认表)
1st ride: 1.15
2nd ride: 1.45
3rd ride: 2.42
假设它是 1.16,那么它会变成这样;
(所需表格)
2nd ride: 1.45
3rd ride: 2.42
如何实现此功能?
最佳答案
使用 HTML
无法做到这一点。
但是,您可以在服务器端执行此操作(通过服务器端脚本,例如 PHP
、ASP
、 perl
、python
或您选择的任何其他内容),或在客户端,通过 JavaScript
:
例如(为了方便和缩短代码,我在这里使用 Javascript
和 jQuery
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/