Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to disable a div in javascript

// This is the DIV you'd like to disable
// Use the CSS selector to pin dow nthe exact DIV
var div = document.querySelector('div');

// Choose either 1, 2 or 3
// (1) Sets the disabled attribute
div.setAttribute('disabled', true);

// (2) Makes the DIV half transparent
// And changes the cursor to a "not allowed" symbol
div.style.opacity = '0.5';
div.style.cursor = 'not-allowed';

// (3) Delete the DIV
div.remove();
 
PREVIOUS NEXT
Tagged: #disable #div #javascript
ADD COMMENT
Topic
Name
4+4 =