There are two links in html document, which i want to open with in same page(not window) but one link content should appear at a time?
<body>
<a href="numbers.html"> Numbers</a>
<a href="data.html"> Data</a>
<div id="show"> </div>
</body>
There are two links in html document, which i want to open with in same page(not window) but one link content should appear at a time?
<body>
<a href="numbers.html"> Numbers</a>
<a href="data.html"> Data</a>
<div id="show"> </div>
</body>
Using jQuery it becomes as simple as using one method called load
.. to make it elegant first add class to your links, e.g.
<a class="loader" href="numbers.html">Numbers</a>
<a class="loader" href="data.html">Data</a>
Then include jQuery and have such code to achieve what you need:
$(document).ready(function() {
$(".loader").each(function(index) {
$(this).click(function() {
$("#show").load($(this).attr("href"));
return false;
});
});
});
This will load the HTML contents into the show
div, replacing any previous contents.
what about you have an event on each link to switch between two divs, hide one and show the other. so it could be:
<div onclick="Show(numbers.html)"> Numbers</div>
<div onclick="Show(data.html)"> Data</div>
and in Show() JS function you have and show the wanted div.