为什么用innerHTML的串,取不到属性值。 少了_, 写成id="divB"了?var temptable = '<div id="_divB">aaa</div>'; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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> 谷歌、火狐下js不能动态创建元素。急!!! EasyUI新组件-拖拽类EasyDragDrop,弹出层基类EasyLayer,遮罩类EasyMask,Popup类 input的type=image的问题 Javascript写的日历程序不显示日期,请教! 大侠们帮我看看这段代码错在哪里 xmlhttp返回的XML中的数组javascript居然不认了。 求万年历算法的详细原理解释 如何让value传递到url中,100分 是否没有可能下载? 一排可以点击的文字,被点击的就高亮显示,这个功能怎样实现的?谢谢 急需!!!可编辑的下拉菜单如何帮定文件上传 attachEvent 顺序
<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>