In jQuery:
e.is(':visible');
checks if an element is displayed or not.
Is there an function in jQuery to check if an element has the attribute visibility to hidden or visible?
Now I have to make that function myself. But i want to use the jQuery function instead if it exists.
The function I made:
$.fn.isVisible = function() {
return ($(this).css('opacity') != '0' && $(this).css('visibility') !== 'hidden');
};
To extend my example: JsFiddle
The real question is: Is there a jQuery function or not?
In jQuery:
e.is(':visible');
checks if an element is displayed or not.
Is there an function in jQuery to check if an element has the attribute visibility to hidden or visible?
Now I have to make that function myself. But i want to use the jQuery function instead if it exists.
The function I made:
$.fn.isVisible = function() {
return ($(this).css('opacity') != '0' && $(this).css('visibility') !== 'hidden');
};
To extend my example: JsFiddle
The real question is: Is there a jQuery function or not?
Share Improve this question edited Apr 28, 2017 at 10:55 Nebulosar asked Apr 28, 2017 at 10:35 NebulosarNebulosar 1,8553 gold badges22 silver badges47 bronze badges 8 | Show 3 more comments2 Answers
Reset to default 17You can check css property visibility is set to visible or hidden.
if ($("#element").css("visibility") === "visible") {
//...
}
or in your case:
$.fn.isVisible = function() {
return $(this).css('visibility') === 'visible';
};
You can use $('#test').css('visibility');
to get the value of visibility
)
in your code – Roko C. Buljan Commented Apr 28, 2017 at 10:37