Click here to Skip to main content
15,875,017 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Create new function onPress Number . I want how it activity when i keydown and keyup?It can't activity.Plz help me.Thanks
JavaScript
(function ($) {
$.fn.onPressNumber = function () { $.fn.keydown(function (e)
 { 
    alert('ffdfd') 
}) 
};
 $.fn.onPressNumber = function () { $.fn.keyup(function (e) 
{ 
    alert('ffdfd') 
})
 };
})(jQuery);   
$('#ffff').onPressNumber();
Posted
Comments
Sergey Alexandrovich Kryukov 24-May-15 11:56am    
You call your function once with jQuery parameter. You don't add any events to HTML elements. What you write does not seem to make any sense. You never show the definition of onPressNumber. The problem of adding event handles is too simple to consider the gibberish I can see in your code sample.

What exactly do you want to achieve?

—SA

1 solution

Your question doesn't make much sense, do you mean you want to add a KeyUp Keydown method to your divs?

easy enough to do like this

JavaScript
$('#idOfDiv').on('keyup keydown',nameOfFunctionToRun);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900