asing function with parameters to onclick an div

asing function with parameters to onclick an div

Hi there.

I love jQuery, but now I reached a line, where I cannot solve the problem.

I have some div-Containers which should call a function when they are clicked. So far so easy. They are named with a name + number, that works also. But how can I give different parameters to the called function?
  1. for (var j = 0; j < i; j++) {

  2. currentDate = new Date( [.......]);
  3. $('#foo' + j + 'graph').unbind();
  4. $(''#foo' + j + 'graph'').attr('onclick', 'functionName(' + currentDate.getUTCFullYear() + ', ' + (currentDate.getUTCMonth() + 1) + ', ' + currentDate.getUTCDate() + ');');
  5. }
This works only in Opera 10.5.
I also tried different other functions like .click() or bind() but they do not work in any browser.

The problem is, that "currentDate" only exist when I bind the function...so it has to bind

  1. "functionName(2010,4,6)"
for example, so that the HTML-Code would be
  1. <div id="foo5graph" onclick="functionName(2010,4,6)">....</div>

Can you please help me?