The 'X' is unable to display "none" to the UL element. Is there a problem with the getElement? or should I use query selector.
function clear() {
  var hide = document.getElementById("myUL1");
  hide.style.display = "none";
}span {
  cursor: pointer;
}<div>
  <ul id="myUL1">
    <li>list</li>
    <li>HTML</li>
    <li>CSS</li>
    <li>JavaScript</li>
  </ul>
  <div>Clear list <span onclick="clear()">X</span></div>
</div> 
     
    