@bnidev/js-utils
    Preparing search index...

    Function toggleInertAround

    • Toggles the 'inert' attribute on all sibling elements of the target element and its ancestors.

      For each ancestor of the target element (up to the document root), this function finds all sibling elements and toggles their 'inert' attribute. If a sibling has the 'inert' attribute, it is removed; otherwise, it is added.

      Parameters

      • target: string | HTMLElement

        The target element or the ID of the target element around which to toggle 'inert' on siblings.

      Returns void

      // ES Module
      import { toggleInertAround } from '@bnidev/js-utils'

      // CommonJS
      const { toggleInertAround } = require('@bnidev/js-utils')
      // Toggle 'inert' around an element by ID
      toggleInertAround('myElementId')

      // Toggle 'inert' around a DOM element
      const el = document.getElementById('myElementId')
      if (el) {
      toggleInertAround(el)
      }