(getProperty
is the deepCss
function from here and retrieves the current (computed) style of an element).
function toggleElements()
{
for (var i = 0; i < arguments.length; i++) {
$(arguments[i])[0].style.display = (
getProperty($(arguments[i])[0], "display") !== "none"
? "none"
: "inline-block");
}
}
I use it like this:
<div id="searchdiv" onclick="toggleElements('#searchoplus',
'#searchominus',
'#search_simple',
'#search_extended');">
which will switch on those elements in the list that weren't visible, and switch off those that were.
I guess I can get rid of the for loop and use jQuery's idiomatic chained-expression syntax, but I don't know how.