I have this code but it gave me only the last selected line!
$('#getLine').click(function(){
console.clear();
$('div').css('color','');
document.execCommand('formatblock', false, 'div');
var line=window.getSelection().focusNode.parentNode;
$(line).css('color','red')
console.log(line);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="editable" contenteditable="TRUE">I am a line<div>I am a new line</div><div>I am the last line</div></div>
<br/>
<input id="getLine" value="Get Line" type="button">
How to get all selected lines even if it was partially selected ? I saw this solution but I don't want selected text only I want to wrap HTML of this lines to change their styles together.