dynamically add attribute to child element

sam

I have a dynamical slider. And trying to add tabindex="-1" attribute to child when it's parent LI element has aria-hidden="true" attribute.

This code is what I am want to be in DOM

<ul class="slider">
  <li aria-hidden="true"><a href="#" tabindex="-1">Link</a></li>
  <li aria-hidden="true"><a href="#" tabindex="-1">Link</a></li>
  <li aria-hidden="false"><a href="#" tabindex="0">Link</a></li>
  <li aria-hidden="false"><a href="#" tabindex="0">Link</a></li>
</ul>

Please help

Poul Bak

You can try this JQuery code:

$('li[aria-hidden=true]').children().attr('tabindex', '-1');

It selects all li elements that have an attribute aria-hidden=true and then sets the attribute tabindex to '-1' for all children; Edit: Fixed the 'dot' typo.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Xsl:attribute Add Element based on child Element attribute value

From Dev

Create div element and dynamically add child elements on it

From Dev

Add data attribute to element and dynamically add value from class name

From Dev

Add data attribute to element and dynamically add value from class name

From Dev

Dynamically add element to layout

From Dev

JAXB add element dynamically

From Dev

Dynamically add/remove element

From Java

XSLT: transform attribute to child element

From Dev

Add css attribute to element

From Dev

Is it possible to add an attribute as an element?

From Dev

How to add dynamically attribute in VueJs

From Java

Dynamically add child components in React

From Dev

How do I dynamically add a ng-pattern attribute to an html element?

From Dev

How do I dynamically add a ng-pattern attribute to an html element?

From Dev

How to get the attribute of a child element based on the attribute of the parent element

From Dev

Add class to dynamically added element

From Dev

Dynamically add specific attr to element

From Dev

Dynamically add element to XML file

From Dev

Add element on top of image dynamically

From Dev

Dynamically add element in JS to XUL

From Dev

Dynamically add element using angularJS

From Dev

Add element on top of image dynamically

From Dev

Add element with attribute to XML in Python

From Dev

Add element with attribute to XML in Python

From Dev

Add class to element if there is a attribute in JQuery

From Dev

How to add a `for=""` and `required=''` attribute to an element?

From Dev

Add class to child element but not to parent

From Dev

add to deepest array child element

From Dev

Add class if child element not present

Related Related

HotTag

Archive