How to call regular JS function with params within jQuery ?

Posted by Kim on Stack Overflow See other posts from Stack Overflow or by Kim
Published on 2010-04-08T11:49:58Z Indexed on 2010/04/08 11:53 UTC
Read the original article Hit count: 294

Is there another way to run a regular JS function with params passed than what I use below ?
It seems redundant use a on-the-way function to do this.

function regularJSfunc(param1,param2) {
  // do stuff
}
$(document).ready(function(){
  $('#myId').change(function(){
      regularJSfunc('data1','data2');
    });
}

Using a .bind event seems much better, however I am not sure how to access the params.
Note: Example below doesnt work.

$(document).ready(function(){
  $('#myId').bind('change',{'data1','data2'},regularJSfunc);
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery