I am trying to hide an HTML div with Javascript and am getting an error
JavaScript runtime error: Unable to get property 'style' of undefined or null reference
Here is my JavaScript code:
if (typeof(jsondata[0]) == 'undefined') {
alert('should be hidden');
document.getElementById("unassignedDevices").style.visibility = "hidden";
}
and here is my HTML:
<div id="unassignedDevices">
<button id="unassignedDevicesbutton" class="button-basicmenu" onclick="findUnassignedDevices();">Find unassigned Devices</button>
<table id="gridunassignedDevices"></table>
</div>
So when I start debugging, the page alerts 'should be hidden' and then I get the JavaScript runtime error.
How can I hide this div?