$('#test').trigger('click');


function trigger(elem, type) {
  if (document.createEvent) {   
    var event = document.createEvent('HTMLEvents');   
    event.initEvent(type, true, false);   
    elem.dispatchEvent(event);  
  } else {   
    elem.fireEvent('on' + type);  
  }

}


var t = document.getElementById('test');
trigger(t, 'click');