I'm going to make a portfolio and am trying to use jquery for effects.
Basically I have several menus and when I click on any of them the showed text in content div of page should change, using ajax. These are levels:
a) SlideUp the #Content div
b) Change the innerHTML of #Content div, using ajax
c) SlideDown, to show the new content

This is the function doing it for me:

function showContent(x){
    $("#content").slideUp("slow", function(){
	var cont = document.getElementById("content");
	if (window.XMLHttpRequest)
	  xmlhttp=new XMLHttpRequest();
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	cont.innerHTML = xmlhttp.responseText;

But the problem is, if for example "menu a"'s text is vertically 300px long, and "menu b"'s textis 200px long. If I first click on "menu a" then click on "menu b" after sliding down the div, it'll go down to 300px then suddenly its height changes to 200px, which is obviously not what I want.

Any help will be appreciated.


Try doing the whole thing in jquery rather than hybrid code:

function showContent(x){
	var $cont = $("#content");
	$cont.slideUp("slow", function(){
			url: x + ".txt",
			type: "GET",
			success: function(data){


Note that $cont---.slideDown("slow"); is inside the success function to give the desired effect (I hope).


Worked perfectly in firefox and chrome. But still has problems with IE -_-
After slideUp, when you change data suddenly the whole data is shown and disappears fast and slides down.. anyway to solve this?


That's very naughty of IE.

I don't know of a workaround but you could try :


Chances are that IE will still misbehave but you never know.


For that kind of stuff I usually use the $(id).load(htmlLocation) function like so: