<button type="button" disabled>This button is disabled</button>
// Makes the button disabled
document.getElementById("myButtonId").setAttribute("disabled", "");
// Removes disabled attribute
document.getElementById("myButtonId").removeAttribute("disabled");
// disable button using prop.
$(".button").click(function(){
// disable button
$(this).prop('disabled', true);
// do something
// below code enables button clicking after two seconds.
setTimeout(() => {
// enable button
$(this).prop('disabled', false);
}, 2000);
});
<button disabled>Click me</button>
<button type="button" disabled={condition? condition_true : condition_false}>Disabled with ternary</button>
ex: disabled={coin > 0 ? buy_a_car() : "No money"}
const textDisabled = text.length === 0 || text.trim().length === 0
/* Selects any enabled <input> */
input:enabled {
color: blue;
}
collector.on('collect', async i => {
if (i.customId === 'id_1') {
row.components[0].setDisabled(true) //disables but_1
}
if (i.customId === 'id_2') {
row.components[1].setDisabled(true) //disables but_2
}
interaction.editReply({ content: "Click a button", components: [row] });
})