少了_, 写成id="divB"了?
var temptable = '<div id="_divB">aaa</div>';

解决方案 »

  1.   

    IE和FF测试都没问题 估计是你的脚本写到body前面了<!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></body>
    </html>
    <script language="javascript">
    var temptable = '<div id="_divB">aaa</div>';
                    var tempdiv = document.createElement("div");
                    with(tempdiv){
                        id = "_divA";
                        innerHTML = temptable;
                    }                
                    document.body.appendChild( tempdiv );
    alert(document.getElementById("_divB"));
    </script>