开发者

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)
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜