Get width/height of invisible DOM elements
When working with elements in jQuery, you might need to get width/height of certain invisible DOM elements. By default, jQuery would return 0 in this case because it can not calculate the actual height()
of that element. In order to solve this problem, I take advantage of jquery.actual
library https://github.com/dreamerslab/jquery.actual
For example, if you have an element with id #test
on DOM, you can do like this:
$("#test").actual('height');
The same thing applied to width
property.
However, there was one issue I had with this plugin when using it in my app while ago. When I run this actual
command multiple times, it made my app slower. Sometimes, it take about 0.5s for this plugin to calculate the height, so please be sure to use it only when necessary.
If you have any better solution, just let me know.
Regards,