3
I have this button, and I need to check with Javascript that it’s disabled, but I don’t know how to do it. Here’s HTML:
<button type="button" title="Finalizar Compra" class="btn btn-proceed-checkout btn-checkout no-checkout" disabled="disabled">
<span>Finalizar Compra</span>
</button>
Are you seeing the disabled="disabled"
? So how do I check this?
What I’ve done is:
var b = document.getElementsByClassName("btn btn-proceed-checkout btn-checkout no-checkout");
if(b == ???) { //Aqui que não sei o que fazer ???
alert("Pedido minimo de: R$: 1250,00");
}
Can you explain something to me please? I program in PHP, but in Javascript I am beginner, I know almost nothing at all. But anyway, the . (point) Javascript is the same thing as PHP -> (arrow)?
– Lucas de Carvalho
@Lucascarvalho I am not the right person to answer about PHP, but as far as I know, are equivalent yes.
– Mathiasfc
Okay, thanks, but can you explain just one more thing? For example, you said collection. In this case, he sees how many items have that class on the page and then organizes from 0 to let’s assume 10 for example. It has 10 buttons with the test class, it will arrange from 0 to 10 on the page and will sort of form an array?
– Lucas de Carvalho
@Lucascarvalho Exactly this, returns a collection of all elements with the specified class, organizing them by index, starting at 0, p/ know how many elements returned, the collection has the property
.length
.– Mathiasfc
Thanks, Mathias! Great day for you! Abs;
– Lucas de Carvalho