jquery keyup在除Firefox之外的所有浏览器 [英] jquery keyup working in all browsers except Firefox

查看:130
本文介绍了jquery keyup在除Firefox之外的所有浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有此代码,以防止人们在文本框中输入£。

I have this code to prevent people entering '£' into a textbox

jQuery(document).ready(function(){
   jQuery('#cp_price').keypress(function(e){
     if(e.keyCode == 163){
       alert("Exclude the £ sign"); 
       return false;
     }
   });
});

它适用于除Firefox以外的所有浏览器。

It works in all browsers except Firefox. Any reason why this wouldn't work?

推荐答案

我认为你需要。

jQuery(document).ready(function(){
   jQuery('#cp_price').keypress(function(e){
     if((e.keyCode ? e.keyCode : e.which) == 163){
       alert("Exclude the £ sign"); 
       return false;
     }
   });
});

这篇关于jquery keyup在除Firefox之外的所有浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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