Pull the function out of the delegated change event (BTW you should use .on()
instead of .delegate()
) and then just call it on document ready.
$('div.tags').delegate('input[type=radio]', 'change', update);
update(); // THIS CALLS THE FUNCTION ON DOC READY
function update() {
var $lis = $('.results > li'),
$checked = $('input:checked');
if ($checked.length) {
var selector = $checked.map(function () {
return '.' + $(this).attr('rel');
}).get().join('');
$lis.hide().filter(selector).show();
} else {
$lis.show();
}
}