开发者

Triggering an event based on changes in the textarea

开发者 https://www.devze.com 2023-01-31 02:01 出处:网络
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

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

精彩评论

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