How to use JQuery to detect value-changed event when user drag & drop text into textbox?

前端 未结 3 829
小鲜肉
小鲜肉 2021-01-03 14:53

I\'m using this jQuery code

$(\'input\').bind(\'change mouseup\', ... )

to detect if user drag text somewhere into my input & change it

3条回答
  •  没有蜡笔的小新
    2021-01-03 15:21

    You can use jQuery paste event with little amount of timeout until the value is pasted if you want to use it or fire a change event. Try this

    $("input").bind('paste', function(e) {
            var $el = $(this);
            setTimeout(function() {
                //Here you can use the pasted value or trigger the text change event
                $el.trigger('change');
            }, 100);
    });
    

提交回复
热议问题