F
F
Fozzy7772021-06-25 01:56:41
JavaScript
Fozzy777, 2021-06-25 01:56:41

How to remove the disabled attribute from a button?

Good day, tell me how to remove the disabled attribute in this case?

<button c-userssnpincheck_userssnpincheck="" title="Continue" disabled="" class="slds-button slds-button_stretch slds-col slds-button_brand">Continue</button>


my attempts were unsuccessful:

document.getElementsByTagName('button')[0].removeAttribute('disabled');

document.getElementsByTagName("slds-button slds-button_stretch slds-col slds-button_brand").removeAttribute('disabled');

document.getElementsByClassName("slds-button slds-button_stretch slds-col slds-button_brand").removeAttribute('disabled');

document.getElementsByClassName("slds-button slds-button_stretch slds-col slds-button_brand").disabled = false;

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Dubrovin, 2021-06-25
@alekcena

You are looking for multiple elements and not 1
Doesn't work because you can't apply ".disabled" to an array
document.querySelector('button').disabled = false

M
MirKey, 2021-06-25
@MirKey

In general, the answer has been given to you, I will add that if you do not want to iterate over the array, then you can use jquery:

$("button .slds-button") .prop( "disabled", false );

Most constructors/engines already have it built in.

T
ThunderCat, 2021-06-25
@ThunderCat

Firstly - you initially gave incorrect data in the question, and despite the presence of the correct answer to it, you could not adapt it to the full code ...
Secondly - there is always the opportunity to check what is happening in your code, for example, what your selector will select, the magic of console .log() in action.
And thirdly - reading the documentation, which you are neglecting - document.querySelector() selects one first matching element, which in your example will be a completely different button.

if you can't think of anything...
document.querySelector('[title="Continue"]') будет более правильным селектором в данном случае

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question