Created
May 11, 2012 21:26
-
-
Save cursedcoder/2662498 to your computer and use it in GitHub Desktop.
This file contains 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
$('textarea').bind('click', function(){ | |
var currentChar = $(this)[0].selectionEnd; | |
var all = $(this)[0].textLength; | |
var line = 0; | |
for (i = 0; i <= all; i++) { | |
var char = $(this).text()[i]; | |
if (char == "\n") { | |
line++; | |
} | |
if (i >= currentChar && char == "\n") { | |
alert(line); | |
break; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment