I am trying to implement tagging just like what facebook does with @friendname. I have a textarea and I wanted to detect when a user typed in @. How do I do so using a keyup listener? Is it possible to get the entered text using keyup? Here's what I have now
$("#recommendTextArea").keyup(function () {
var content = $(this).val(); //content Box Data
var go = content.match(start); //content Matching @
var name = content.match(word); //content Matching @friendname
console.log(content[content.length-1]);
//If @ available
if(go.length > 0)
{
//if @abc avalable
if(name.length > 0)
{
//do something here
}
}
});
Most importantly what I need is the index of the'@' that the user just entered.