<div class="content" contenteditable="true">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
JavaScript-Code hierfür istWie die Zeilennummer des Cursors in Absatz bekommen
var divheight = $(".content").height();
var lineheight = $(".content").css('line-height').replace("px","");
alert(Math.round(divheight/parseInt(lineheight)));
css ist
.content {
line-height:20px;
}
zum Beispiel, wenn der Klick innerhalb .content
die <span class="cursor"></span>
.cursor {
border-left: 1px solid black;
margin-left: -1px;
color: #2E3D48;
}
, wie die .cursor
zu finden, ist inder Zeilennummer .content
gerade versucht Mockup Geige
https://jsfiddle.net/1ok3dah9/
Wenn es umwickelt, gibt es technisch keine Zeilennummer. Ich nehme an, Sie suchen nach einer Pseudo-Zeilennummer? –
Nicht klar, was Ihr Ziel wirklich ist. –