If an element is visible or hidden using jQuery

Usually you can trust the .toggle function (or .slideToggle) to hide or show whatever you want it to. But occasionally you need to know if something is hidden or shown.

var isVisible = $(‘#giftMsg’).is(‘:visible’);
var isHidden = $(‘#giftMsg’).is(‘:hidden’);

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous post unsolved: jQuery: Can you redefine the click function on a button? (unsolved mystery)
Next post How to get the current action & controller name in Rails