I have been searching all over for an answer to this and nothing seems to be relevant. Sorry if there is another similar question.
I am trying to put multiple pages on to just an index.html page, and therefore am trying to make clicking on a menu button replace text within my content div.
I have tried using .replaceWith(); .empty() and append() (and .appendTo() ), and have found that the following works, but only once. I am quite new to coding and therefore any responses in Laymans terms would be greatly appreciated. :)
My HTML: ......
<div id="menubar">
<ul>
<a href="index.html"><h6>Home</h6><a/>
<h6 id="buildServ">Building Services</h6>
<h6 id="maintServ">Maintenance and Handyman Services</h6>
<h6>Garden Services</h6>
<h6>Gallery</h6>
<h6>Contact Me</h6>
</ul>
</div>
<div id="content" style="padding:10px;marginleft:50px;width:40%;height:auto;float:left;border:3px solid white;border-radius:15px;background-image:url('menuGrad.jpg');background-repeat:repeat-x;behavior: url('PIE.htc');">
<div id="textDiv">
<p>this is where the homepage text will go</p>
</div><!-- textDiv -->
<div id="textDiv2" style="display:none;">
<p>this is where the building services text will go</p>
</div><!-- textDiv2 -->
<div id="textDiv3" style="display:none;">
<p>this is where maintenance services text will go</p>
</div><!-- textDiv3 -->
</div><!-- content -->
and the jQuery: ...
<script>
$("#buildServ").click(function(){
$("#content").html($("#textDiv2"));
$("#textDiv2").show();
});
$("#maintServ").click(function(){
$("#content").html($("#textDiv3"));
$("#textDiv3").show();
});
</script>
Once I have clicked on #buildServ it works, but then I click #maintServ and try to go back to #buildserv and it clears the #content .
Hope this is clear, if any other info is required to assist please let me know.