$('.class').prop("disabled", true);
$('#id').prop("disabled", true);
// As function
const disable = (id) => $(`#${id}`).prop("disabled", true);
$("#navigation ul li").unbind("click");
function disable(i){
$("#rbutton_"+i).prop("disabled",true);
}
function load(recieving_id){
$('#roommate_but').prop('disabled', true);
$.get('include.inc.php?i=' + recieving_id, function(data) {
$("#roommate_but").html(data);
});
}
// 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").attr("disabled", true);
//---------------------OR--------------------
jQuery("#button").attr("disabled", true);
// use jQuery instead of $ to avoid conflict with other JS libraies.