I need my plugin to detect element's line-breaks, here is the code:
$.fn.inlineOffset = function (){
if ($(this).css('text-indent') == '0px' && $(this).height() != 17) {
var el = $('<i/>').css('display', 'inline').insertBefore(this[0]);
pos = el.offset();
el.remove();
return pos;
}
else {
var pos = $(this).offset()
return pos;
}
};
As you can see, it would only work if element's height is 17px. But what if I need to set different height? I need this solution, because if I try to add element before first letter in new line it appears at top left corner of it's parrent and I only need to add when the line of text is broken.