开发者

Firefox element height issue

开发者 https://www.devze.com 2023-01-14 03:14 出处:网络
I am creating a table dynamically based on the number of rows returned from the server using struts. The table is created properly and I am trying to get the height value on the created table using an

I am creating a table dynamically based on the number of rows returned from the server using struts. The table is created properly and I am trying to get the height value on the created table using any of the following:

document.getElementById('elementId').offsetHeight
jQuery("#elementId").css('height')
jQuery("#elementId").height()

I have run my code using Chrome and they all return the proper height of the table.开发者_StackOverflow The issue I am having is with Firefox. Any of these run with Firefox is always returning a value of 0.

I have tried placing the code in a $(document).ready(), $(window).load(), and in a window.load = function(){} call, but none of them are returning a value. When I run the code in Chrome it returns a value of 136 for the height and when I run the same code in Firefox, it returns a value of 0 every time.

Is there something I am missing? Any help would be greatly appreciated.


Try wrapping the table in a div and get the height of the div.


It may be a case of how your setting the size on you table dynamically.

Try either of the following:

alert(document.getElementById("myElement").clientHeight);

alert(document.getElementById("myElement").style.height);


Moin is on to something - I had to wrap a table in a DIV to get its height. But if your next step is to SET the height this won't work in FF:

$("#ID").height(123)

You need to do this instead

$("#ID).css("height", 123)

NO idea why.

0

精彩评论

暂无评论...
验证码 换一张
取 消