开发者

Triggering an event based on changes in the textarea

I need a hidden div to show up the moment one of two things happen

  1. The user presses "@", and then p开发者_Python百科ress any other non-whitespace character

  2. 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;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜