I have a function called foo
which is supposed to return the current visible element, but returns undefined
instead.
function foo(){
$('.bar').on('shown', function(){ // 'shown' is a bootstrap .js event
return ($(this).attr('id').split('baz')); // returns 'undefined'
});
}
According to Pointy's answer here, it does not make sense to return values from event handlers. If that's the case, what would be the conventional way to retrieve the return of foo();
when needed?