Skip to content

Instantly share code, notes, and snippets.

@cursedcoder
Created May 11, 2012 21:26
Show Gist options
  • Save cursedcoder/2662498 to your computer and use it in GitHub Desktop.
Save cursedcoder/2662498 to your computer and use it in GitHub Desktop.
$('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