alert
我的代码可以在经过时间的同时弹出对话框。
我怎样才能做同样的事情,但在 HTML 而不是 JavaScript 对话框中?
我必须用与 AJAX 相关的东西来做吗?
谁能给我一个例子,好吗?
jQuery(document).ready(function () {
var comments = [{'time':'5','message':'hello! 5 secs has past'},{'time':'10','message':'hello! 10 secs has past'},{'time':'30','message':'hello! 30 secs has past'}];
$('#video').on('timeupdate',function(e){
showComments(this.currentTime);
});
function showComments(time){
var comments = findComments(time);
$.each(comments,function(i,comment){
alert(comment.message);
});
}
function findComments(time){
return $.grep(comments, function(item){
return item.time == time.toFixed();
});
}
});
HTML
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Show sequential messages in HTML</h1>
<p>
**Messages appears here instead of dialog**
</p>
</body>