jQuery keyup检测输入中的粘贴文本 [英] jquery keyup detect paste text from input

查看:202
本文介绍了jQuery keyup检测输入中的粘贴文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在这里使用jquery keyup来检测用户是否输入了任何文本,但是我的问题是,如果用户使用鼠标粘贴文本,它将无法检测到它,你能告诉我原因吗?

I have to use here jquery keyup to detect if user enter any text or not, but my problem is if user use paste the text using mouse, it won't be able to detect it, can you tell me the reason?

这是我的源代码:

$("textarea").keyup(function(){
        if($(this).val().length !== 0){
            $('#submit').attr('disabled',false);

推荐答案

显然,在某些情况下jQuery无法进行粘贴.您可能需要绑定到以下参考资料中所示的几个事件,才能准确捕获粘贴内容的用户.

Apparently there are some situations where jQuery doesn't work for pasting. You might need to bind to several events as shown in following reference to catch users pasting contents accurately.

来自

这篇关于jQuery keyup检测输入中的粘贴文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆