基本上,我想做的事: 当您按下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
@你可以详细解释答案吗? –