w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to make a website load only a certain div(class) to save load time, using JavaScript
<html>
    <head>

    </head>
    </body>
<a href="file1.html">File 1</a> | 
<a href="file2.html">File 2</a>

<br><br>
<div class="the-container">Contain will be load here!</div>


<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(function(){
    $('a').click(function(e){
        e.preventDefault();
        $('.the-container').text('Please wait...');
        $('.the-container').load($(this).attr('href'));
    })
})
</script>

load() method required server.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.