Writing functions as variables

Writing functions as variables

I am new to jQuary and although I can write functions I can only seem to write a function for everything! One of the methods people use at work is writing functions as variables to cut down on code. However I just can’t grasp this – I find it confusing. Are there any tutorials for doing this particular method?

Example below

  1. $('.PatchyTopPopUpDiv').click (function () {

  2. var ToolTipLink = "#";

  3. var ToolTipImage = $(this).attr('id');

  4. var ToolTipDiv = "Div";

  5. var EmailTool = "-Email";

  6. var ShowToolTip =ToolTipLink+ToolTipImage+EmailTool

  7. $(ShowToolTip).fadeIn ();

  8. });