Get HTML with jQuery by pressing button

0

I have a simple system that takes the HTML of a file and places it in a single dynamic index . Example:

<a onclick="carregar('cartaonatal/natal.html');" href="#">Agradecimento</a>

//chama a função

function carregar(pagina){
    $("#conteudo").load(pagina);
}

The loaded HTML is placed inside div #conteudo . What I wanted was to load a load or print to div with some simple visual animation.

Is this possible?

    
asked by anonymous 04.12.2017 / 02:33

1 answer

2

You can use .fadeOut with callback , and then with .fadeIn() of the element itself with another callback of .load() :

function carregar(pagina){
   $('#conteudo').fadeOut(function(){
       $(this).load(pagina, function(){
           $(this).fadeIn();
       });
   });
}
    
04.12.2017 / 03:16