Reputation: 13166
I have a simple HTML like this:
Get alert with inserting a + sign: <input type="text" class="data" />
I want alert user whenever he/she press + key. But my jQuery code does not work:
$(document).ready(function(){
$(".data").bind('keydown',function(e){
if(e.which == 107){
alert('Plus sign entered');
});
});
});
What do I have to do ?
(This is my jsFiddle)
Upvotes: 0
Views: 663
Reputation: 50019
There were two things wrong in this code.
The following code fixes it
$(document).ready(function(){
$(".data").bind('keydown',function(e){
if(e.which == 107 || e.which == 187){
alert('Plus sign entered');
}
});
});
Here's the fiddle - http://jsfiddle.net/DgUUB/
Upvotes: 1