Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Small block of code not working on IE


Sub_Seven - 12:02 am on Aug 29, 2012 (gmt 0)


Hello everyone,

I have a block of code that sets the height of a div on the fly depending of the size of the first list item under an unordered list; it works ok under Chrome and Firefox but as always Internet Explorer is acting up so I thought I'd ask here for some help, this is the code:

<script type="text/javascript">
function setSize(){
var firstLi = $('#hotelSlider').show().find('li:first-child'),
firstHeight = firstLi.height(),
container= $('#hotelSlider');
container.css({
'height': firstHeight + 'px'
});
}
</script>


I'm running it onload like this: "<body onload="setSize()">"

The only thing that I've tried is changing the height property like so:

<script type="text/javascript">
function setSize(){
var firstLi = $('#hotelSlider').show().find('li:first-child'),
firstHeight = firstLi.css('height'),
container= $('#hotelSlider');
container.css({
'height': firstHeight
});
}
</script>


But it doesn't make a difference, any ideas as to why this happens?

Thanks :)


Thread source:: http://www.webmasterworld.com/javascript/4489307.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com