多维数组和时间戳
Multi-dimensional array and timestamp
代码如下:
var array = [];
$('.body-watch-logo').each(function () {
array[]['evendId'] = $(this).data('event');
array[]['timestamp'] = $(this).data('timestamp');
$now = new Date();
$outStr = now.getHours()+':'+now.getMinutes();
alert($outStr);
if(array[]['timestamp'] == $outStr) {
alert('Tring Tring Tring');
//do something here
}
$i++;
});
。body-watch-logo中有几个事件,属性为eventId和startTime。我想把这些信息存储在数组中。然后比较只有小时和分钟的startTime与current-time。如果相等,则发出警报。有人知道怎么做吗?可以使用Ajax。请建议。
您增加了i
,但从未初始化它或将其用作数组索引。但是您不需要这样做,因为.each()
将索引作为参数传递给迭代函数。看到
数组的元素最好作为对象实现,而不是子数组。
var array = [];
$('.body-watch-logo').each(function (i) {
array[i] = { event: $(this).data('event'),
timestamp: $(this).data('timestamp')
};
$now = new Date();
$outStr = now.getHours()+':'+now.getMinutes();
alert($outStr);
if(array[i].timestamp == $outStr) {
alert('Tring Tring Tring');
//do something here
}
});
相关文章:
- 用每小时的差值填充数组/列表-从下拉列表中给定两个时间值
- 从javascript数组获取php的日期时间
- 在jquery中对时间数组进行排序
- 添加时间数组的元素
- 如何在数组中循环,等待每个项目之间的时间
- 用javascript将日期时间数组拆分为子日期
- 如何对Javascript Unix时间戳数组进行排序
- Javascript:以时间戳为键的数组
- 按时间戳对对象数组进行排序
- 如何使用javascript创建一个具有当前时间和下一个10个5分钟间隔时间的数组
- 使用php和json将mysql时间戳数组转换为javascript日期数组
- 在jquery中按时间戳对数组进行排序
- 正在分析字符串以获取与单词相关联的时间戳数组
- 多维数组和时间戳
- 我如何寻找和采取快照从时间戳存储在数组中的秒/ NO jQuery
- 使用javascript查找o(n)时间1D数组中的所有子数组
- 如何匹配和获取日期从时间戳数组在js
- 如何根据当前时间在数组中查找即将发生的事件
- 将时间戳的 Javascript 数组按小时、天分解为较小的数组
- 包含时间戳的数组.当当前分钟中的秒=数组中每个时间戳值的秒时,从数组中推送