javascript - onPaste event on jquery not update while using mouse - Stack Overflow

I use the onpaste event for detect the paste in input element. It works fine when we paste using ctrl +

I use the onpaste event for detect the paste in input element. It works fine when we paste using ctrl + v but I use mouse to paste rightclick + paste it wont update the value. What I do wrong in here. Can anyone assist me.

$("input").on("keyup paste",function(){
      $("#result").text($(this).val());
});

Jsfiddle

Thanks in advance

I use the onpaste event for detect the paste in input element. It works fine when we paste using ctrl + v but I use mouse to paste rightclick + paste it wont update the value. What I do wrong in here. Can anyone assist me.

$("input").on("keyup paste",function(){
      $("#result").text($(this).val());
});

Jsfiddle

Thanks in advance

Share asked Jul 12, 2013 at 7:07 user2073289user2073289 1451 gold badge2 silver badges7 bronze badges 4
  • Have you tried the paste event? not keyup paste – auo Commented Jul 12, 2013 at 7:09
  • keyup is for while typing in the input element. I bind the multiple event keyup and paste thats all. – user2073289 Commented Jul 12, 2013 at 7:11
  • 1 @AndreasLindgren, if you have nothing to say, then don't say anything - jQuery on(...) accepts multiple events separated by space. – ElmoVanKielmo Commented Jul 12, 2013 at 7:13
  • Thanks for letting me know that @ElmoVanKielmo, I didn't know it – auo Commented Jul 12, 2013 at 7:14
Add a ment  | 

2 Answers 2

Reset to default 7

Just try this:

$('input').bind('input propertychange', function() {
    $("#result").text($(this).val());
});

And the fiddle is here http://jsfiddle/Frnc7/

You have to add a timeout...

$('input').on('paste', function () {
  setTimeout(function () {
    $('#result').text($('input').val());
  }, 100);
});

See jsFiddle

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742290370a4416077.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信