最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论