Rob
Rob

Reputation: 37

How do I use CSS to change tags with visibility:hidden to display:none css

On my site (no example, it's company facing), I am calling someone else's JS code that writes html to the page. Unfortunately they are using visibility:hidden rather than display:none in an element with no class id. I need to know the easiest way to target the elements with visibility:hidden and change them with display:none, preferably without using 3rd party solutions.

Is there any way to use css to target elements with certain styles already set, or to change the default behavior of visibility:hidden to take up no space?

Upvotes: 0

Views: 1444

Answers (1)

jackJoe
jackJoe

Reputation: 11148

try this:

$('selector').each(function() {
if ($(this).css("visibility") == "hidden") {
    $(this).css('display', 'none');
}});

P.S. just edited my JS, now it works perfectly :)

Upvotes: 2

Related Questions