Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

jQuery: Animate height to auto

Using jQuery, how can I animate the height to auto?

This does not work:
.animate({height: 'auto'}, 900);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Demo</title>

<style type="text/css">
#leadForm1 {height: 0; overflow: hidden; width: 700px;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>

<script type="text/javascript">
/* <![CDATA[ */

function CreateText($min,max)
{
 var l= l = ('Lorem ipsum ');
 var validchars = "eir mod tem por invidunt ut lab ore dol ore magna aliqu yam erat sed diam voluptu ";
  var minsize, maxsize, count, actualsize;
  minsize = Math.floor(Math.random()*100);
  maxsize = Math.floor(Math.random()*9000);
  if (maxsize<(Math.ceil(maxsize * 1.5)))
  var str = (Math.ceil(maxsize * 1.5));
  actualsize = Math.floor(Math.random() * (maxsize - minsize + 1)) + minsize;
    for (count = 1; count<actualsize; count++)
    l=l+validchars.charAt(Math.floor(Math.random()* validchars.length));
  return l;
}

$(document).ready(function(){

$('#rq1').click(function() {
  $('#leadForm1').html(CreateText());
  $('#leadForm1').animate({height: '650px'}, 900);
  $(this).css( {visibility: "hidden"})
  return false;
});

});

/* ]]> */ 
</script> 

</head>
<body>

<p><a href="#" id="rq1">Click Here</a></p>

<div id="leadForm1"></div>
<hr />
<h1>Hello World</h1>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of amischol
amischol

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial