I have two links at index.html
to target.html
.
first link is simple. it's just goes to target.html.
but I want to do something else with the second link.
simply:
1-user clicks the second link to target.html
2-not only target.html
appears but also show-this-page-in-target.html-if-user-clicks-the-second-link.html
appears in .page-class
element with the help of jQuery load()
function.
What I'm able to do so far?
I can load the page I want when I'm in target.html already with the codes below:
HTML
<a href="#" id="load" class="btn btn-primary">Load</a>
JavaScript
<script type="text/javascript">
$('#load').click(function(){
$('.page-class').load('show-this-page-in-target.html-if-user-clicks-the-second-link.html .target-class')
});
</script>
But I don't know how to load them when I go that page via link.
This is your second link to taget.html:
<a href="target.html#load" class="btn btn-primary">Load</a>
in target.html use this code:
<script>
if(window.location.hash === '#load') {
$(function() {
$('.page-class').load('show-this-page-in-target.html-if-user-clicks-the-second-link.html .target-class')
});
}
</script>
Should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With