开发者

Handle when text in a text box changes

开发者 https://www.devze.com 2023-03-27 16:53 出处:网络
I need to change text in a text box with jQuery, before onBlur and without using key events. For example, if the text in the box was changed without the user typing any input, I could handle that ev

I need to change text in a text box with jQuery, before onBlur and without using key events.

For example, if the text in the box was changed without the user typing any input, I could handle that event.

I've tried using $('input.myInput').change(), but the event only fires after开发者_运维问答 the user tabs off of that text box.

Any help is appreciated.

Many thanks!


Simply put, there isn't and event for value/attribute change (called a Mutation Event) built into jQuery.

There are some plugins out there; however, YMMV with them. I hope you find something that works for you!

Good luck.


I ran into this a while back, the best method i came up with is to bind other events that would change the value.

   $('input.myInput').bind('paste cut keyup mouseup change', function () {
           //Do Stuff
      });
0

精彩评论

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

关注公众号