Search code examples
javascriptinternet-explorergoogle-chromemozilla

Why this JavaScript doesn't work?


This is my code:

function habilitarsistemas() {
    if (document.getElementById("ChkSistemas").checked)
        document.getElementById("tabelasistemas").style.display = "block";
    else
        document.getElementById("tabelasistemas").style.display = "none";
}

It works fine with Firefox but it doesn't with IE and Chrome. Why?


Solution

  • jQuery solution.

    function habilitarsistemas() {
      if ($('#ChkSistemas').is(':checked')) {
        $('#tabelasistemas').css({ display: 'block' });
      }
      else {
        $('#tabelasistemas').css({ display: 'none' });
      }
    }