我正在尝试让 JQuery 更改 div 标签的内容,使其看起来像用户正在浏览多个页面。我的方式是用户将点击一个按钮,一旦他们点击该按钮,脚本将运行并更改 div 的内容。我希望至少有三页这样完成,但是在第二页之后我遇到了问题。这是我在脚本中的内容:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#1").click(function() {
$("#leftPart").html('<input type="text" id="blash" value="blash" name="blash" ><input type="text" id="hello" value="hello" name="hello" ><input type="text" id="world" value="world" name="world" ><input type="button" name="submit" id="2" value="Submit" />');
$("#rightPart").html('');
});
$("#2").click(function() {
$("#rightPart").html('<input type="text" id="meep" value="meep" name="meep" ><input type="text" id="glomp" value="glomp" name="glomp" >');
});
});
因此,一旦我单击第一页上的按钮,ID 为“1”,它就会将屏幕更改为第二页应显示的内容。第二页将显示一些内容并创建另一个 ID 为“2”的按钮。然后,当我尝试单击第二页中的按钮时,ID 为“2”,它什么也没做。有什么帮助吗?是因为按钮是用脚本创建的,而不是实际在 html 中?