我一直在寻找答案,没有任何关系。对不起,如果有另一个类似的问题。
我试图将多个页面放在index.html页面上,因此我试图在菜单按钮上单击替换内容div中的文本。
我曾尝试使用.replaceWith(); .empty()和append()(和.appendTo()),并发现以下工作,但只有一次。我对编码相当陌生,因此对Laymans术语的任何回应将不胜感激。 :)
我的HTML:
......
this is where the homepage text will go
this is where the building services text will go
this is where maintenance services text will go
...
$("#buildServ").click(function(){
$("#content").html($("#textDiv2"));
$("#textDiv2").show();
});
$("#maintServ").click(function(){
$("#content").html($("#textDiv3"));
$("#textDiv3").show();
});
一旦我点击了#buildServ,它就可以工作,但是我点击#maintServ并尝试返回#buildserv并清除#content。
希望这是明确的,如果有其他信息需要协助,请让我知道。