Tuesday, May 22, 2012

Pass parameters to function call in event trigger

Right now I have this



jQuery('.widget-prop').keyup(function() {
var prop = jQuery(this).attr('id');
var val = jQuery(this).val();

stuff;
}


and



jQuery('.widget-prop').click(function() {
var prop = jQuery(this).attr('id');
var val = jQuery(this).val();

stuff;
}


two functions are the same, so I'd like to simplify it by defining external function and calling it with



jQuery('.widget-prop').click('myFunction');


but how would I pass parameters to myFunction?



function myFunction(element) {
stuff;
}


Thanks





No comments:

Post a Comment