mydiv.innerHTML='<div align="right" id="ipclose" style="width:450px;height:16;background:#f9f9f9"><span style="font-size:14px;font-weight:600;cursor:pointer" onclick="del();">关闭</span></div> '+function del()
{
$("#online").bind("click");
var cdiv = document.getElementById("ip"); 
cdiv.parentNode.removeChild(cdiv);
}
提示del未定义。怎么解决

解决方案 »

  1.   

    这些问题你就应去看书的,太基础的东东。下面的Copy 我的代码,---html 文件上运行一下看看符不符合你的要求。<!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> <script type="text/javascript">
    function del() {
    document.getElementById("mydiv").innerHTML="";
    }
    function insertDiv() {
    document.getElementById("mydiv").innerHTML = '<div align="right" id="ipclose" style="width:450px;height:16;background:#f9f9f9"><span style="font-size:14px;font-weight:600;cursor:pointer" onclick="del();">关闭</span></div>'
    }
    </script></head>
    <body>
    <div id="mydiv"></div>
    <input type="button" id="showDiv" value="展示DIV" onclick="insertDiv();" />
    </body>
    </html>