javascript - 根据行号划分 html div,即。每个 div 10 行具有固定高度并执行分页以使用 jquery 读取 div 的下 10 行

标签 javascript jquery html css pagination

我想按行数划分div,对div进行分页操作。 div 的样式和对齐方式应保持不变。有一个限制条件是 div 的高度是固定的。

$.fn.numLines = function() {
    var tmp = $('<div style="visibility:hidden;">x</div>').appendTo(document.body);
    var lines = this.height() / tmp.height();
    tmp.remove();
    return lines;
};

$('#change').keyup(function() {
    $('#test').html(this.value.replace(/\n/g, '<br />'));
    $('#lines').text($('#test').numLines());
}).keyup();
#test {
    border: 1px solid #000;   
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
lines: <div id="lines"></div>
<br />
<div id="test"></div>
<br />
<textarea id="change" rows="10" cols="40">
<div id="target" class='holder-description'>
    <table style="width:100%"><tbody><tr><td style="width:45%">NS 1 DENGUE ANTIGEN</td><td style="width:19%">negative</td><td style="width:18%"></td><td style="width:18%"></td></tr></tbody></table><p><span style="font-family: Arial; font-size: 13px;">COMMENTS:</span></p>
<p><span style="font-family: Arial; font-size: 13px;"></span><span style="font-family: Arial; font-size: 13px;">Accurate and timely diagnosis of dengue virus is important for early detection of dengue virus infection. In this study, the usefulness of the dengue NS1 antigen test was evaluated as a routine, rapid diagnostic test for dengue virus infection. A total of 208 sera from patients suspected of having dengue virus infection were collected and tested for dengue antibody, dengue genome and dengue NS1 antigen. Dengue antibody test, dengue PCR test and dengue antigen test were able to detect dengue virus infection from Days 1 to 8 in 72.8, 52.8 and 44.0% of samples, respectively. Of the 208 sera tested, 69.2% (144/208) of the acute sera were positive for dengue virus infection based on IgM antibody, IgG antibody, NS1 antigen and PCR tests. Thirty-two point two percent of the samples (67/208) were found positive for dengue NS1 antigen, 38.5% (80/208) were PCR positive, 40.9% (85/208) were IgM positive and 36.1% (75/208) were IgG positive for dengue virus. The results reveal the detection rate of dengue virus infection was similar for PCR and dengue antibody (65.9%) and for NS1 antigen and dengue antibody (62.0%) combinations. Therefore, the dengue NS1 antigen test can be used to complement the current antibody test used in peripheral laboratories. Thus, the combination of the NS1 antigen and antibody tests could increase the diagnostic efficiency for early diagnosis of dengue infection.</span></p><table style="width:100%"><tbody><tr><td style="width:45%">DENGUE IgG</td><td style="width:19%">negative</td><td style="width:18%"></td><td style="width:18%"></td></tr></tbody></table>COMMENTS:<br>
<br>
The presence of three pink coloured line indicate the presence of specific Igm &amp; IgG antiboidies against virus. The presence of of two pink coloured line one test line Igm within test zone closer to the sample well &amp; one conrol line in control zone indicate presence of IgM antibodies against dengue virus. The presence of two pink coloured line one test line IgG within test zone closer to control zone or away from sample zone and one control line in control zone indicate presence of IgG antibodies against Dengue virus.<br>
In primary dengue fever IgM antibodies can be detedtes as early as 3-5 days after the fever, where as IgG antibodies are negative. In secondary Dengue fever IgG antibodies are positive &amp; IgM antibodies may be also be positive secondary dengue fever is a second infection with same or different sero type and is often associated with the complication as dengue haemorrhagic fever and dengue shock syndrome.<br>
A few patients of Dengue fever may not produce detectable levels of antibodies within 7-10 days after infection and test result may show negative for antibodies . If symptoms persist a retest after 5-7 days is recommented.<br>
The serological cross reactivity across the Flavi virus group is commom i.e. between dengue 1,2,3,4, murray valley encephalitis, japnese encephalitis and yellow virus.<br><table style="width:100%"><tbody><tr><td style="width:45%">DENGUE IgM</td><td style="width:19%">negative</td><td style="width:18%"></td><td style="width:18%"></td></tr></tbody></table>COMMENTS:<br>
This test determines simultaneously for the presence of IgM and IgG antibodies to Dengue virus. The total is panreactive to Dengue viruses 1,2,3 and 4. Serum IgM antibodies can be detected as early as three to five days after the onset of fever and generally persist for 30 to 90 days. It may be detected as long as eight months post-infection.Secondary infection is characterized by high IgG antibody levels and may be accompanied by elevated IgM levels.<br>
<br>
Primary Dengue: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IgM detected<br>
<br>
Secondary Dengue:Both &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IgM &amp; IgG detected<br>
<br>
Secondary Dengue suspected : &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IgG Detected<br>
<br>
Negative: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IgM &amp; IgG not detected<br><div style="text-align:center;"> *****EOR****<br>Powered by cloudchowk</div></div>
</textarea>

最佳答案

使用 em CSS 单元;

在 CSS 中,有很多度量单位,其中两个在您的情况下非常有用。

em : 相对于元素的font-size(2em表示当前字体大小的2倍)...

您可以在 this w3schools.com article 阅读更多关于单位的信息

在你的情况下<div style="height:10em;">...<div>是要走的路...

关于javascript - 根据行号划分 html div,即。每个 div 10 行具有固定高度并执行分页以使用 jquery 读取 div 的下 10 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33542998/

相关文章:

javascript - 如何判断浏览器/选项卡是否处于事件状态

javascript - 如何在下拉列表更改时动态隐藏表格行?

html - 如何确定 float 元素影响非 float 元素高度的原因(D7 views blocks with zen theme)?

html - 将图像插入文本并使用 CSS 保持文本换行

javascript - 我怎样才能动画这个?

javascript - Angular/Karma - $http.get 未执行

javascript - jQuery AddClass 然后删除一个类

javascript - asp.net 中的 RegularExpressionValidator 不适用于 1 位或 2 位数字

javascript - 我可以根据某个对象的属性值找到该对象吗?

javascript - 图层堆叠问题