How do I get a string within a certain height of div?

for example: a div with a height of 600px containing the content of the article. I want to get the string within the height of the div 300px. Can it be achieved?

Jun.10,2021

  1. get the padding font size. A series of spacing or something. Figure it out by yourself
  2. assign a value to it character by character. Until the div exceeds your threshold.

these things actually depend on you, for example, they happen to have an average height in the 300px, but they are generally not there. So does this business count.


var arr = [];
$.each($('div'),function(i,item){
    if($(item).height()<=300){
       arr.push($(item).text())
    }
})
Menu