Javascript Style How to - Change style visibility








Question

We would like to know how to change style visibility.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--   w  w w .java 2s  .c o  m-->
    var countyFieldLabel = document.getElementById('lcity').nextElementSibling;
    countyFieldLabel.style.visibility = "hidden";
}
</script>
</head>
<body>
  <label name="lcity" id="lcity" for="city" class="formLabel" title="City">City:</label>
  <span class=spanclass>*</span>
</body>
</html>

The code above is rendered as follows: