它會完成方法中的所有操作(例如警告/ div加載),但拼接不起作用。所以我想要做的是當用戶點擊「刪除」按鈕時,該特定的視頻從陣列中刪除。我的陣列不會拼接
代碼:
function updateFavourite(video) {
document.getElementById("favourite").onclick = function() {
blacklist[video["id"]] = true;
myfavourite.push(video);
var html =
"<input class='removeButton' value='Remove' type='button' />" +
"<li class=\"saved\">" +
"<img class= \"img-rounded\" src=\"{0}\"/>" +
"<p><b title=\"{2}\"><a class=\"extendedLink\" href=\"javascript:watchHistoricVideo(\'{1}\');\"><span></span>{2}</a></b><br>" +
"by {3}<br>" +
"{4} | {5} views</p>" +
"</li>";
$("#myfavourite").prepend(html.format(video["thumbnail"],
video["id"],
video["title"],
video["uploader"],
video["length"],
video["views"]));
$("#myfavourite .removeButton").click(function() {
myfavourite.splice(video, 1);
setVideoF(video);
alert("Removed");
document.getElementById("myfavourite").innerHTML = '<div id="myfavourite"></div>';
$("#loadFavourite").trigger('click');
});
setVideoF(video);
}
}
你還沒有問過這個問題嗎? http://stackoverflow.com/questions/21894835/how-do-i-splice-my-array – putvande
你怎麼知道「我的陣列不會拼接」? – PeeHaa