try it like this, .is() returns true or false so you have to use it in an if statement:
$("a.saveConfig").click(function() { if ($('div.detail').is(':visible')) alert('Hey this works'); }); dennis. Pete wrote:
I'm trying to create a link that when clicked will produce an alert if there are any visible divs (all .detail divs are hidden by default). I have the following function but it doesn't seem I'm doing it correctly; nothing happens regardless of the visibility status of the divs. $("a.saveConfig").click(function() { $('div.detail').is(':visible'), (function () { alert('Hey this works'); }); }); Is there a better way to do an if statement using JQuery selectors or is there something I'm missing in my code?