I need to control a div's height to always appear in steps of 20. I have a repeating div background that is 20 pixels high and I want the div to always end in a correct way. I found what I think is the solution here: Set height of an element on multiples of a number?
But when I try it doesn't work. I'm a newbie at jquery and probably made a simple mistake.
In the following test html code I'm expecting the div's height to always appear in steps of 100px, but it doesn't work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://`enter code here`www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test jquery</title>
<script type="text/javascript" src="jquery.js"></script>
<script language=”javascript”>
$(document).ready(function(){
$('#testCol').height(function(i, h) { return Math.ceil(h / 100) * 100; });
});
</script>
<style type="text/css">
#testCol {
width: 150px;
background-color:#FFCC00;
}
</style>
</head>
<body>
<div id="testCol">df ds d sfdhs fdsf ds fhsdu ds iuhsdi fsdf dhsf sdiuh isdf iusd fiushd fiuds i uhsdiu isudf iusd fiusdh fiusd fih wtwpr wer rew</div>
</body>
</html>