-1

I have the below JavaScript which works fine in Internet Explorer(IE)

function disableDiv() {
    disablebutton(document.getElementById("pageWidth"))
}
function disablebutton(el) {
    try {
        el.disabled = el.disabled ? false : true;
    }
    catch (E) {
    }
}

and I'm calling this within a JavaScript function

function updatediv() {
    if (document.getElementById("sbtotals") != null) {
        document.getElementById("sbtotals").style.display = "none";
    }
    disableDiv();    
}

in IE el.disable works fine but not in Chrome or Firefox. What should I do to this to work in all 3 browsers?

Harry
  • 87,580
  • 25
  • 202
  • 214
rushd
  • 223
  • 1
  • 5
  • 10
  • @jAndy: Lol, I missed that while editing. I guess it was a typo for JavaScript. – Harry Oct 08 '13 at 11:37
  • 1
    Is 'pageWidth' an HTML button? Provide a piece of HTML code which contains an element with ID 'pageWidth' – Max Koretskyi Oct 08 '13 at 11:39
  • @rushd: We have made some corrections to the question. Please check if they are inline with what you meant. Also show your HTML markup. – Harry Oct 08 '13 at 11:43
  • Check this topic http://stackoverflow.com/questions/5985839/bug-with-firefox-disabled-attribute-of-input-not-resetting-when-refreshing – Max Koretskyi Oct 08 '13 at 11:45
  • I guess this is a repeated question. Please refer to: http://stackoverflow.com/q/639815/2134166. You can create a class and add/remove it to disable/enable divs. – cristianzamar Mar 09 '16 at 14:59

2 Answers2

3

Divs can't be disabled. Only form and form elems

Liauchuk Ivan
  • 1,913
  • 2
  • 13
  • 22
1

You cannot 'disable' a div. Instead you can set it's CSS display property to 'none'.

Bas Slagter
  • 9,831
  • 7
  • 47
  • 78
  • what i am realy tying to do is graying out the div for till while a some process are taken place. how can i grayout the div not hinde appreicate ur help – rushd Oct 08 '13 at 12:47
  • You can add an (absolute positioned) overlay div in the element on which you can apply some styling like opacity and background color. Make this element 100% height and 100% with and set it's display property to block when it needs to be displayed. – Bas Slagter Oct 08 '13 at 13:44