基本上,我想做的事: 當您按下button
#change
,在div
#board
內容必須改變,以無非是:更改HTML內容,然後改回
<h2>Hi!</h2>
<button type="button" onclick="ChangeAgain();">
然後,當您單擊button
,它變回它曾經是,那就是:
<h2>Welcome to this page.</h2>
<p>It's quite boring in here. Why don't you click the button?</p>
<button onClick="Change();">Button for you to Click</button>
這裏是我的JavaScript(jQuery的3.2.1),這是行不通的。
$(function() {
var inThere = "";
function Change() {
inThere += $("#board").html();
$("#board").html("<h2>Hi!</h2> \n
<button type=\"button\" onclick=\"ChangeAgain();\">")
}
function ChangeAgain() {
$("#board").html(inThere);
}
})
不要包起來文件準備好處理 – Satpal
@你可以詳細解釋答案嗎? –