---
title: "火狐不支持event.keyCode，用jquery中的event.which轻松解决。"
author: "piperzero"
date: "2013-07-15T16:41:00Z"
tags: []
slug: "event-keycode-jquery-event-which"
draft: false
lastmod: "2013-07-16T08:39:51Z"
id: 1906924
url: "https://piperzero.iteye.com/blog/1906924"
---

```
	$(':text[name="price"]').keypress(function(e) {
		if (e.which == 46
				|| ((e.which >= 48 && e.which <= 57)|| e.which == 8||e.which==0)) {
			return true;
		} else {
			alert("只可以输入数字哦！");
			$('#go').attr('disabled','disabled');
			return false;
		}
	});//0代表选择了esc
```