我的代碼可以在流逝的時間同時彈出alert
對話框。我該如何做同樣的事情,但在HTML而不是JavaScript對話框中?
我該如何做同樣的事情,但在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>
你需要閱讀什麼HTML和AJAX是 – zerkms
我想他所要求的是有一個HTML覆蓋,而不是一個警告對話框。顯而易見,他將它描述爲'我怎樣才能做到**相同的事情,但是在HTML中卻沒有JavaScript對話框? – 2013-08-21 02:28:43
@remyabel是的。這正是我想要問的。對不起我的可憐的解釋。 – MKK