how to simulate click in javascript code example

Example 1: simulate a user click

// element.click simulates an user click
// doesn't work on <a> tags
document.getElementById("myCheck").click();

Example 2: js simulate click

document.getElementById('elementID').click();

Example 3: javascript perform click

function eventFire(el, etype){
  if (el.fireEvent) {
    el.fireEvent('on' + etype);
  } else {
    var evObj = document.createEvent('Events');
    evObj.initEvent(etype, true, false);
    el.dispatchEvent(evObj);
  }
}

Example 4: javascript perform click

eventFire(document.getElementById('mytest1'), 'click');