tags:

views:

38

answers:

1

Hi,

i have a little question. Is it possible to call the keyup function with an extra value?

For example

$('#eld').keyup(function test(e,val2){
    test('','hallo');

But this will not work. Any ideas? Kind regards Peter

+1  A: 

What you can do is, pass custom data through the .trigger() method of jQuery.

For instance.

$('#eld').keyup(function(e, val2){
  alert(val2);
});

Now you can trigger the keyup with

$('#somebutton').click(function(){
    $('#eld').trigger('keyup', ['custom data']);
});

You can pass an array of custom data through .trigger() as second parameter.

Example: http://www.jsfiddle.net/V9Euk/

jAndy
Ow thats nasty. Just don't push enter to close the alert ;)
Thqr
Nice, it works ^^Thanx for the fast answer :)
Peter