Created
June 21, 2013 15:58
-
-
Save kswlee/5832210 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var rect = { | |
| leftTop: {x: $this.offset().left + 2, y: $this.offset().top + lineHeight / 2}, | |
| bottomRight: {x: $this.offset().left + $this.width() - 2, y: $this.offset().top + limitHeight - lineHeight / 2} | |
| }; | |
| var rangeStart = doc.caretRangeFromPoint(rect.leftTop.x, rect.leftTop.y); | |
| var rangeEnd = doc.caretRangeFromPoint(rect.bottomRight.x, rect.bottomRight.y); | |
| var range = doc.createRange(); | |
| range.setStart(rangeStart.startContainer, rangeStart.startOffset); | |
| range.setEnd(rangeEnd.startContainer, rangeEnd.startOffset); | |
| var html = $('<div>').append($(range.cloneContents())).html(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment