I am trying to emulate static variables in a JavaScript function with the following purpose:
$.fn.collapsible = function() {
triggers = $(this).children('.collapse-trigger');
jQuery.each(triggers, function() {
$(this).click(function() {
collapse = $(this).parent().find('.collapse');
})
})
}
How to save the object "collapse" so that it is not "found" with every call? I know that with the help of these functions I could do something like "someFunction.myvar = collapse", but what about anonymous functions like this?
Thanks!
source
share