Be careful if the animation is animated, you cannot check the visibility of the div immediately after the "switch" call. You must use the switch function callback argument.
Example:
duration = 0;
$("#"+div).toggle(duration,function(){
var txt = $("#"+div).is(':visible') ? 'Details' : 'Changes';
$("#l_detail").html(txt);
});
Documentation: http://api.jquery.com/toggle/
source
share