Skip to content
Related Articles
Open in App
Not now

Related Articles

How to Display/Hide functions using aria-hidden attribute in jQuery ?

Improve Article
Save Article
  • Last Updated : 20 Sep, 2021
Improve Article
Save Article

The ‘aria-hidden’ attribute plays an important role in context of web-accessibility. It is a simple way to make web content/applications more accessible to people with disabilities. This attribute is used to indicate that the element and all of its descendants are not visible or perceivable to any user as per the implementation. Now in your mind may a question arrived that what is the difference between ‘hidden’ and ‘aria-hidden’ attributes?
The main aspect of making this solution is to make content readable only when content is visible on screen otherwise should remain inaccessible. Here, we’ll be using attr() method to do the same which is used for setting/getting an element’s attribute.

Getter: $([selector]).attr('attribute');
Setter: $([selector]).attr('attribute', 'value');

Below example illustrate the above approach:


<!DOCTYPE html>
    aria-hidden attribute on JQuery Show/Hide functions
    <!-- Added support for BS3 and jQuery using CDN -->
    <link rel="stylesheet" href=
    <script src=
    <script src=
    <script src=
        .access {
            margin-left: 90px;
    <div class="row">
        <div class="col-sm-4">
            <!-- button to toggle attribute -->
                <button class="btn btn-success">
        <div class="col-sm-8">
            <!-- Attribute's value -->
<p><i>aria-hidden</i> attribute's value :
                  <span id="answer">false</span>
    <div class="container-fluid">
        <div class="access" aria-hidden="false">
            <!-- For Content accessibility -->
            <h1 class="text-success">
              A Computer Science portal for Geeks
        $(document).ready(function() {
            $('button').click(function() {
                /*Check and alternate attribute's value,
                then show/hide accordingly using chaining. */
                if ($('.access')
                    .attr('aria-hidden') == 'true')
                    .attr('aria-hidden', 'false')
                    .attr('aria-hidden', 'true')
                // Display changed attribute's value



My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!