我调用Prduct,传递参数变量_outhtml让_tabletemp得到他的值,但_tabletemp是对象。

解决方案 »

  1.   

    <script>
    function Product(_outhtml) { var _tabletemp=document.createElement("<table>") _tabletemp.innerText=_outhtml;         return _tabletemp}Product("this way we go");
    </script>
      

  2.   

    对于 table select 等特殊的几个对象用 innerHTML 的时候会出错的, 你换一种做法吧, 直接组织HTML语句, 效率比你的 createElement 还要来得快:
    function Product(_outhtml)
    {
      var _tabletemp= "<table border=1>";
      _tabletemp += _outhtml;
      _tabletemp += "</table>";
      return _tabletemp
    }
    document.write(Product("<tr><td>content</td></tr>"));
      

  3.   

    直接按照下面这样就可以了
    function Product(_outhtml) {
    var _tabletemp=document.createElement(_outhtml)
             return _tabletemp
    }
      

  4.   

    我的目的是返回一个对象,如果组织html,返回的就不是对象了
      

  5.   

    组织html的时候可以给table一个id,然后可以根据id来访问这个table