css disable button code example

Example 1: javascript how to disable a button

//Using Javascript
//Disabling a html button

document.getElementById("Button").disabled = true;
//Enabling a html button

document.getElementById("Button").disabled = false;


//Using jQuery
//Disabling a html button

$('#Button').attr('disabled','disabled');
//Enabling a html button

$('#Button').removeAttr('disabled');

Example 2: style disabled button

button:disabled,
button[disabled]{
  border: 1px solid #999999;
  background-color: #cccccc;
  color: #666666;
}

Example 3: css disable button click

button.disabled{
  pointer-events: none;
}

Example 4: html button disabled

Example 5: css for disabled button

/* CSS Selectors for CSS2 and CSS3 both */
button:disabled,
button[disabled]{
  border: 1px solid #999999;
  background-color: #cccccc;
  color: #666666;
}

Tags:

Misc Example