我有一个函数可以获取一些数据并生成各种叠加窗口。这会附加一个按钮来关闭窗口。我不知道为什么,关闭按钮的 .click 永远不会被触发(警报甚至不会发生)。以下是相关功能。
//This is what gets appended
function createOpponentMenu(item1, item2) {
$('<div id="matchMenu"><div id="vs">VS</div><div id="opponent1">' + item1.media + '<div id="vote1">VOTE</div><div class="desciption-container"><h2 class="match-hed">' + item1.name + ' | <span style="font-family:SupriaSans-Regular">' + item1.when + '</span></h2><p class="match-text"><span style="color:red;font-family:SupriaSans-Bold">OFFENSE:</span> ' + item1.offense + '</p><p class="match-text"><span style="color:green;font-family:SupriaSans-Bold">OUTCOME:</span> ' + item1.outcome + '</p></div></div><div id="opponent2">' + item2.media + '<div id="vote2">VOTE</div><div class="desciption-container"><h2 class="match-hed">' + item2.name + ' | <span style="font-family:SupriaSans-Regular">' + item2.when + '</span></h2><p class="match-text"><span style="color:red;font-family:SupriaSans-Bold">OFFENSE:</span> ' + item2.offense + '</p><p class="match-text"><span style="color:green;font-family:SupriaSans-Bold">OUTCOME:</span> ' + item2.outcome + '</p></div></div><div id="matchup-close">Close X</div></div>').appendTo('#bracket-container').fadeIn("slow");
}
// This decides what to append
$(".matchup-container").click(function() {
for(var i=0; i<matchups.length; i++) {
if(this.id == "matchup" + (matchups[i].match).toString()){
createOpponentMenu(matchups[i].id1, matchups[i].id2);
}
}
});
//now I just want to kill the whole thing on close click
$('#matchup-close').click(function() {
alert("wtf");
$('#matchMenu').fadeOut("slow").remove();
});