在Div jQuery中查找内容的行号

时间:2015-07-22 05:52:26

标签: jquery

import re
from datetime import datetime, timedelta

def string_to_delta(s):
    value = int(re.search(r'\d+', s).group())
    if "day" in s:
        value = value*1
    elif "month" in s:
        value = value *30   
    date_ago = (datetime.now() - timedelta(days=value)).date() 
    str_date= date_ago.strftime("%d %B %Y")
    return str_date

我试图在一个div中找到一些内容的行数。 div高度将是固定的。怎么解决?请帮助。 https://jsfiddle.net/id10922606/n94u3Lb2/1/

1 个答案:

答案 0 :(得分:0)

以下是获取潜水内容行号的演示:

http://jsfiddle.net/brunoscopelliti/EPms9/

$(document).ready(function() {
  	var divheight = $("#startegy-sections-targeting-exclude").height(); 
	var lineheight = $("#startegy-sections-targeting-exclude").css('line-height').replace("px","");
	alert(Math.round(divheight/parseInt(lineheight)));
});
#startegy-sections-targeting-exclude {
	line-height:20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="startegy-sections-targeting-exclude">
  Something strange... <br/>maybe it's fault of the measure unit<br/>PX!
</div>