输入文本上的jQuery Mobile Paste事件 [英] Jquery Mobile Paste event on input text

查看:114
本文介绍了输入文本上的jQuery Mobile Paste事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jquery Mobile开发适用于Android和iPhone的网络应用程序.当用户在输入文本字段中更改其值时,我想处理该事件.

I'm using Jquery Mobile to develop an web app for Android and iPhone. I want to handle the event when the users change their value in the input text field.

最初,我使用.on("keyup change"),一切似乎都正常.但是,当用户在文本字段上粘贴一些文本(按住并点击粘贴")时,不会调用我的事件处理程序.

Initially, I use .on("keyup change") and everything seem to work ok. However, when the users paste some text on the text field (by holding and tap on the "Paste"), my event handler is not called.

如果您知道如何解决此问题,请帮助我.

Please help me if you know how to solve this problem.

谢谢大家.

推荐答案

可在所有浏览器上使用,但不能在FireFox上使用.

演示

Demo

$('input').on('paste', function (e) {
 if (e.originalEvent.clipboardData) {
  var text = e.originalEvent.clipboardData.getData("text/plain");
  $('p').empty();
  $('p').append(text);
 }
});

贷方转到: jQuery在页面上的任意位置检测粘贴事件,然后重定向";它到Textarea

这篇关于输入文本上的jQuery Mobile Paste事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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