<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<div id="a"></div>
<script>
window.onload=function(){  var GridTable = function(){ 
var o = this; this.tt = function(){alert('1');}; 

this.show = gridshow;
}

function gridshow(){
var o = this;

var b  = document.createElement('input');
b.type = "button";
b.name = "b";
b.id = "b";
b.value = "按钮";

b.onclick = function(){ o.tt() };

document.getElementById('a').appendChild(b);
}

grid1 = new GridTable(); 
grid1.show(); } </script></body>
</html>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body>
    <div id="a"></div>
    <script>
    window.onload=function(){  var GridTable = function(){ 
    var o = this; this.tt = function(){alert('1');}; 

    this.show = gridshow;
    }

    function gridshow(){
    var o = this;

    var b  = document.createElement('input');
    b.type = "button";
    b.name = "b";
    b.id = "b";
    b.value = "按钮";

    b.onclick = function(){ o.tt() };

    document.getElementById('a').appendChild(b);
    }

    grid1 = new GridTable(); 
    grid1.show(); } </script></body>
    </html>