Pete wrote:
I guess I'm still not getting "else" out of this. I thought I had it
figured out
I think what's confusing to me as a n00b is that "if" does not seem to
be closed. How would I accomplish an else condition?
I highly recommend to make yourself familiar with JavaScript control
structures. jQuery can do a lot for you but you still need to know the
basics of JavaScript...
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Conditional_Statements#if...else_Statement
What do mean by "not closed"?
You can use an if statement without curly braces if there's only one
statement to be executed:
if (condition) alert('yes');
or
if (condition)
alert('yes');
Together with else:
if (condition) alert('yes');
else alert('no');
I tend to always use curly braces, that makes it easier to add another
line to the conditional blocks and to me it's easier to read, but that's
just a personal taste I guess. You'll need them anyway to group multiple
statements in a block:
if (condition) {
alert('yes');
alert('I said yes');
} else {
alert('no');
alert('I said no');
}
Back to your example:
$("a.saveConfig").click(function() {
if ($('div.detail').is(':visible')) {
alert('Hey this works');
} else {
alert('Hey this doesn't work');
}
});
HTH
--Klaus