开发者

How to pass parameter to $.keyup() ?

开发者 https://www.devze.com 2022-12-08 06:15 出处:网络
I want to do something 开发者_如何学编程like : function validateBody($obj) { } $ojb.keyup(validateBody($ojb));

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

精彩评论

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