I was under the assumption that if I disabled a div, all content got disabled too.
However, the content is grayed but I can still interact with it.
Is there a way to do that? (disable a div and get all content disabled also)
I was under the assumption that if I disabled a div, all content got disabled too.
However, the content is grayed but I can still interact with it.
Is there a way to do that? (disable a div and get all content disabled also)
One way to achieve this is by adding the disabled prop to all children of the div. You can achieve this very easily:
$("#myDiv")
finds the div,.find("*")
gets you all child nodes in all levels and.prop('disabled', true)
disables each one.This way all content is disabled and you can't click them, tab to them, scroll them, etc. Also, you don't need to add any css classes.
This css only/noscript solution adds an overlay above a fieldset (or a div or any other element), preventing interaction:
If you want an invisible i.e. transparent overlay, set the background to e.g. rgba(128,128,128,0), as it won't work without a background. The above works for IE9+. The following much simpler css will work on IE11+
Chrome
The disabled attribute is not part of the W3C spec for DIV elements, only for form elements.
The jQuery approach suggested by Martin is the only foolproof way you're going to accomplish this.
Browsers tested: IE 9, Chrome, Firefox and jquery-1.7.1.min.js
If you are simply trying to stop people clicking and are not horrifically worried about security - I have found an absolute placed div with a z-index of 99999 sorts it fine. You can't click or access any of the content because the div is placed over it. Might be a bit simpler and is a CSS only solution until you need to remove it.
I would use an improved version of Cletus' function:
Which stores the original 'disabled' property of the element.