解决方案 »

  1.   


    (function($){
                var e=this;
                this.create = function(){
                    for (var i = 0; i <10; i++) {
                        var html=$('<a href="#" >for-'+i+'</a><br/>');
                        html.click(function(){
                            method.call(this);
                        });
                        $("body").append(html);
                    };
                }
                var method = function(){
                    alert($(this).text());
                }
                this.create();
            })($);
      

  2.   

    示例
    function Test()
    {
    this.create=function()
    {
    var ele=document.createElement('a');
    ele.href="#";
    ele.innerHTML='点击';
    ele.onclick=this.methed;
    document.body.appendChild(ele);
    }
    this.methed=function()
    {
    alert('123');
    }
    }
    window.onload=function()
    {
    var obj=new Test();
    obj.create();//
    }
      

  3.   


    更正下methed 方法有参数的
    ele.onclick=this.methed;参数怎么添加?
      

  4.   

    function Test()
    {
    this.create=function()
    {
    var ele=document.createElement('a');
    ele.href="#";
    ele.innerHTML='点击';
    var that=this;
    ele.onclick=function(){
    that.methed('测试');
    };
    document.body.appendChild(ele);
    }
    this.methed=function(msg)
    {
    alert(msg);
    }
    }