好吧,我一直卡在這一小會兒現在....click在使用replaceWith後停止工作
基本上我有兩種方法我想要顯示某個div。我打算用replaceWith()替換#mainDiv和另一個版本的#mainDiv來創建一個函數。
下面是函數:
function switchToChoice(){
$('#myCanvas2').replaceWith('<div id="yesBox" width="150" height="90"><img id="yes" src="Yes-Button.png" width="110" height="55"></div><div id="noBox" width="150" height="90"><img id="no" class src="No-Button.png" width="110" height="55"></div>');
}
這工作,並創建格框我想,當它被調用。 div盒中有兩個圖像,可點擊,但不執行點擊操作。
這是不是replaceWith工作後的一段代碼:
//If the user presses the Next button on the comment pages.
$('#next').click(function() {
$('#next').fadeTo(100, 0.25, function(){
clearCanvas(ctx, c);
wrapText(ctx, questionList[textPos], x, y-20, 275, 15);
textPos++;
});
switchToChoice();
$('#next').fadeTo(100, 1);
});
//If the user presses the Yes button on the question pages.
$('#yes').click(function() {
alert("boobs");
$('#yes').fadeTo(100, 0.25, function(){
clearCanvas(ctx, c);
wrapText(ctx, questionList[textPos], x, y-20, 275, 15);
textPos++;
});
$('#yes').fadeTo(100, 1);
});
//If the user presses the No button on the question pages.
$('#no').click(function() {
$('#no').fadeTo(100, 0.25, function(){
clearCanvas(ctx, c);
wrapText(ctx, questionList[textPos], x, y-20, 275, 15);
textPos++;
});
$('#no').fadeTo(100, 1);
});
我的猜測是,HTML被替換時,有些東西失去了,但我真的不知道是什麼。我對JQuery相當陌生,並且儘可能地做了大量的研究,但似乎我只是圍繞着圈子。誰能幫忙?
對不起,我沒有包括他們。對於#yes和#no div框還有兩個.click()調用。它們與我爲#next發佈的內容基本相同。我更新了這個問題。 – lonewookie 2013-05-06 00:40:31
#no和#yes的.click是那些不起作用的。 – lonewookie 2013-05-06 00:43:03
剛剛查看我的編輯。 – taylonr 2013-05-06 00:46:36