My question is more about Javascript memory and best practices than a
specific problem, but I will use the following example to illustrate:

I have a div, which I would like to have a minimum height of 600 px. If I
put 600px as the height in the .css file, the div will not expand for
content that is larger. So, I am using JQuery to determine if the content is
less than 600px and if it is I will adjust the css height to 600px. (Yes, I
am aware of the JQMinMax plug-in - again, this is a more general question)

------------------------------------------------

$(document).ready(function(){

 function resizeDiv(that){
  var x = $(that);
  if(x.height() < 600){
         x.css("height","600px");
        }
 };

 $("#mydiv").each(function(){resizeDiv(this)});

});

--------------------------------------------

My question: is it better to define this function as above and pass "this"
or to define an anonymous function within the .each statement? I read that
the above method only has to compile the function once, as opposed to a
re-compile each time the (anonymous) function runs. What is the recommend
way of doing this?

-- 
View this message in context: 
http://www.nabble.com/External-or-anonymous-function---which-is-best--tf3109294.html#a8618915
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to