How to pass parameter to $.keyup() ?
I want to do something 开发者_如何学编程like :
function validateBody($obj)
{
}
$ojb.keyup(validateBody($ojb));
How to do it the right way?
This will do what you are looking for:
function validateBody(e) {
var $obj = e.data.obj;
// do something
}
$ojb.bind('keyup', { obj: $ojb }, validateBody);
Check out the documentation on event.data and bind
I believe this is what you want, correct?
function validateBody(obj, number) {
//do something...
}
$ojb.keyup(function() {
var someNumber = getNumberFromAlgorithm();
validateBody($(this), someNumber)
});
精彩评论