Triggering an event based on changes in the textarea
I need a hidden div to show up the moment one of two things happen
The user presses "@", and then p开发者_Python百科ress any other non-whitespace character
The user copies and pastes "@xxx" into the system, where @xxx is any string that starts with "@"
I am having quite a bit of issues with this in jQuery - any help would be much appreciated! =)
Try using the textchange plugin by Zurb, that adds a textchange event which you can bind to.
What you can do then:
var prev;
$('#tf1').bind('textchange', function() {
var cur = $(this).val();
//TODO compare prev & curr, check you condition
prev = cur;
});
精彩评论