the important thing is not to stop questioning

导航

 

        window.onload = function() {
            for (var i = 1; i < 4; i++) {
                var id = document.getElementById("a" + i);
                //id.onclick = (function(i) {
                //    return function() {
                //        alert(i);
                //    }
                //})(i);
                id.onclick = function (i) {
                    alert(this);
                    return function () {
                        alert(this);
                        alert(i);
                    }
                }(i);
            }
        }

posted on 2016-04-01 16:43  qook  阅读(125)  评论(0编辑  收藏  举报