How to set `aria-disabled` to true using JavaScript

I have no idea about JS. But in my Ruby I need one line of code. I have below html .

 <div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"> <div class="ui-dialog-buttonset"> <button class="otherButtonClass ui-state-hover ui-state-focus" type="button" role="button" aria-disabled="false"> <button class="otherButtonClass" type="button" role="button" aria-disabled="false" style="display: none;"> <button class="cancelButtonClass" type="button" role="button" aria-disabled="false"> </div> </div> 

I want the JS code to make the first and second buttons to make them visible. What will be the code?

Please, help.

+4
source share
3 answers

http://jsfiddle.net/SQ7SH/1/

 var buttons = document.querySelectorAll('.ui-dialog-buttonset button'); buttons[0].setAttribute('aria-disabled', true); buttons[1].setAttribute('aria-disabled', true); 

Also button requires tag tag

+5
source
 var buttons = document.getElementsByClassName('otherButtonClass'); for(var i = 0; i < buttons.length; i++){ buttons[i].setAttribute('aria-disabled', 'true'); } 
+1
source

As given there is needed one line of code :

 document.querySelectorAll('.ui-dialog-buttonset .otherButtonClass').forEach(function (item) {item.setAttribute('aria-disabled', true);}); 
+1
source

Source: https://habr.com/ru/post/1489683/


All Articles