This works:
var toggler = function(most){ var open = $(\'#toggle_\' + most + \' .minus\').is(\':visible\'); if(open){ $(\'#toggle_\' + most
it is because of wrong use of a closure variable in a loop
In this case since you are iterating through an array, you can use $.each()
var t = ['mostviewed','mostshared','mostrecent']; $.each(t, function(_,most){ $('#toggle_' + most).click(function(){ toggler(most) }); })