What variables are available inside a .click(function(){}) function?

What variables are available inside a .click(function(){}) function?

Hi folks,

I think I'm fundamentally misunderstanding either JavaScript or jQuery .click handlers? I had assumed the function assigned to the click event could only see global variables and those inside the function. However it appears to be able to see those around it when the event is created?


I have

   
  1. function addAssessmentClick(courseID, assessmentID) {
  2.         jQuery("#assessment" + assessmentID).click(function() {
  3.                 console.debug("clicked courseID:"+courseID+" assessmentID:"+assessmentID);
I wouldn't have expected courseID and assessmentID to be available inside the click function, however this is not the case.

Any thoughts?

Cheers!

Paul.