Here's one implementation, what works like $.prop(name[,value])
or $.attr(name[,value])
function. If b
variable is filled, visibility is set according to that, and this
is returned (allowing to continue with other properties), otherwise it returns visibility value.
jQuery.fn.visible = function (b) {
if(b === undefined)
return this.css('visibility')=="visible";
else {
this.css('visibility', b? 'visible' : 'hidden');
return this;
}
}
Example:
$("#result").visible(true).on('click',someFunction);
if($("#result").visible())
do_something;