js中onclick报错,不知是什么原因

     //定义Init的方法
    Init.prototype = {
        changeColor: function($obj) {
            var opencolor=this.options.openColor;
            var closecolor=this.options.closeColor;
            document.getElementById("switch").onclick(function(){
                alert("aaa");
            })

存js和jquery搞混了
==》

  document.getElementById("switch").onclick=function(){
                alert("aaa");
            }

Uncaught TypeError: Cannot set property 'onclick' of null at Init.changeColor
你上面这句话的意思就是Init.changeColor是null,也就是说后面的定义未生效。
建议在《body》中 增加onload=init();
init=function(){

  //定义Init的方法
    Init.prototype = {
        changeColor: function($obj) {
            var opencolor=this.options.openColor;
            var closecolor=this.options.closeColor;
            document.getElementById("switch").onclick(function(){
                alert("aaa");
            }) 

}