I have this code. opacity 0 and opacity 1 works! but load(pagina) don’t load. Why?
function cargarContenido(pagina) {
$('#content').animate({"opacity":"0"});
if ($('#content').css('opacity') == 0) {
$("#content").load(pagina);
}
$('#content').animate({ "opacity": "1" });
}
If i put only this, it works fine
function cargarContenido(pagina) {
$("#content").load(pagina);
}
You need to use the callback parameters of the
animateandloadmethods to execute your code in sequence. Try this:Note I’ve expanded the formatting of this code to make it clear what’s happening. You can remove a lot of the spacing to make it shorter if required.