var $body = $('body');
var $edit = $('.edit');
$edit.each(function (i, el) {
var $el = $(el);
var top = $el.position().top;
\t var $bar = $('<div/>', {
class: 'edit-bar',
style:
'top:' + top + 'px;' +
'height:' + $el.height() + 'px;'
});
$body.append($bar);
});
body {
margin: 0;
}
p {
margin-left: 3rem;
}
.edit {
background-color: yellow;
}
.edit-bar {
position: absolute;
left: 10px;
border-left: 5px solid black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente cupiditate, eligendi delectus voluptas. Dolore laborum nostrum consectetur incidunt, debitis animi eum vel expedita amet deleniti eaque sed voluptates, consequuntur ut. <span class="edit">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente cupiditate, eligendi delectus voluptas. Dolore laborum nostrum consectetur incidunt, debitis animi eum vel expedita amet deleniti eaque sed voluptates, consequuntur ut.</span> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente cupiditate, eligendi delectus voluptas. Dolore laborum nostrum consectetur incidunt, debitis animi eum vel expedita amet deleniti eaque sed voluptates, consequuntur ut.
</p>
<p>
Sapiente cupiditate, eligendi delectus voluptas. Dolore laborum nostrum consectetur incidunt, debitis animi eum vel expedita amet deleniti eaque sed voluptates, consequuntur ut. <span class="edit">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente cupiditate, eligendi delectus voluptas.</span> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente cupiditate, eligendi delectus voluptas.
</p>