What am I missing in jQuery, aria-disabled and disabled selector?

Using strings like

$('#myButton').button({ 'disabled' : true }); 

I would expect this to match the CSS selector: disabled, but it is not. The button is explicitly disabled, but it has the following properties:

 class="button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-disabled ui-state-disabled" role="button" aria-disabled="true"> 

I understand that this aria-disabled thing is not an IE provider prefix , but why doesn't it have the usual old "disconnected"? Did I do something wrong? I am going from classes in which we use the jQuery user interface, which I know very little about (I was looking for errors in someone else's code).

+4
source share
2 answers

If button not called in the form element :disabled will not select it.

From the docs :

The: disabled selector should only be used to select HTML elements that support the disabled attribute ( <button> , <input> , <optgroup> , <option> , <select> and <textarea> ).

If it is used, for example, to style the <a> tag, you will need to select one of the ui- classes, for example. ui-state-disabled .

+2
source

Perhaps try using the attr() function and set it to disabled, since I don't know if disabled = true.

 $('#myButton').attr('disabled', 'disabled'); 
0
source

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


All Articles