Smithy Smithy - 3 months ago 21
Javascript Question

Find all display:none attributes and add in aria-hidden attribute using JavaScript

Is there a way to search for all the instances where property

display:none
is used and add the attribute
aria-hidden="true"
using JavaScript.

My site has hundreds of instances of this and i am looking for a quicker way.

Could it be something like this: (added to a function)

$(*).css( "display", "none" ).attr( "aria-hidden", "true" );

Answer

use hidden() selector to identify all display none element

$( ":hidden").attr( "aria-hidden", "true" );

DEMO