Posts Tagged ‘javascript disable DIV Firefox’

Today, I was searching for a solution to enable/disable DIV element using javascript. I have tried so many code, but all are working in IE only and not supported by FF (firefox). At last I found some solution which is helpful. I thought this might also useful to you.

Copy/Paste following javascript code snippet.
<script type="text/javascript">
function toggleAlert() {
function toggleDisabled(el) {
try {
el.disabled = el.disabled ? false : true;
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {

Copy/Paste following HTML code in BODY tag:

<div id="content">
<td><input type="text" name="foo" /></td>
<select name="bar">
<input type="checkbox" value="toggleAlert()" onclick="toggleAlert()" />

Here, I have used one checkbox, by clicking which you can enable/disable child controls of a DIV. However, you can use any element other than checkbox (e.g button, radio button, etc…)