Out of curiosity, how can you determine if a div is full?
Full example :
The above image shows a filled div, because there is no space to continue typing, the word hello filled the limit of the div
.
Example that it is not full (because it still has space below to continue writing)
full != not empty
As @A.Cedano says "determining if it is full depends on various factors such as font size".
Can this example help? http://jsfiddle.net/yfSUk/3
Here I use a wrapper to prevent the code snippet from interfering, the trick is to check the
clientHeight
against thescrollHeight
.In the case of div one it is visible, in the case of div three it is hidden by a container
One thing you could do is create a clone of the element, add a character to it, and check if the height of the element has changed. If it changed, it means that it was full and did not admit more. If the height is the same, it means there was still room for more text.
To do this you can create a function like this:
And here you can see it working:
In jQuery you can use the select
empty
as follows, knowing that being filled means having something, even if it's just white space.If a div is full? The function you posted has nothing to do with what you ask, I invite you to fix your question or else this is the answer.
It uses the
.html()
jquery method to fetch what is inside a selector.Cheers