I have got my contentEditable div
:
div {
width: 200px;
height: 300px;
border: 1px solid black;
}
<div contenteditable="true" spellcheck="false" style="font-family: Arial;">
<b>Lorem ipsum</b> dolor sit amet, <u>consectetur adipiscing elit.
Morbi sagittis</u> <s>mauris porta arcu auctor, vel aliquam ligula ornare.</s>
Sed at <span id="someId">semper neque, et dapibus metus.
Maecenas dignissim est non nunc feugiat</span>
sollicitudin. Morbi consequat euismod consectetur. Mauris orci
risus, <b>porta quis erat ac, malesuada</b> fringilla odio.
</div>
<button>Get current line HTML</button>
And I want to create a button which gives me HTML code from the current line. For example:
When my caret is on the second line I want to get:
amet, <u>consectetur</u>
or on seventh line:
<span id="someId">dapibus metus. Maecenas</span>
I tried to do that using Rangy, but that didn't work. How can I do that using JavaScript and/or JQuery?
Thanks for help.