function showDiv(){
var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
div.style.display = "inline";
div.innerHTML = "hello, world.";
window.document.appendChild(div);--加上这一句就可以了!
div.focus();
}
var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
div.style.display = "inline";
div.innerHTML = "hello, world.";
window.document.appendChild(div);--加上这一句就可以了!
div.focus();
}
var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
div.style.display = "inline";
div.innerHTML = "hello, world.";--这句最好变成:div.innerText="hello, world.";
window.document.appendChild(div);--加上这一句就可以了!
div.focus();
}
ABCDE<script>
function showDiv(){
var div = document.createElement("<div style='color:red;display:inline;'>");
div.innerHTML = "hello, world.";
document.activeElement.insertAdjacentElement("afterEnd",div);
}
</script>
ABCDE<script>
function showDiv(){
var div = document.createElement("div");
div.style.top = 300;
div.style.left = 300;
div.style.backgroundColor = "red";
div.style.display = "inline";
div.innerHTML = "hello, world.";
document.body.appendChild(div);
}
</script>这段代码我测试着没有什么问题呀。PS:innerText insertAdjacentElement 都是IE独有的东东,若是考虑代码的兼容性的话,最好还是不要使用这些属性方法
现在日历的程序已经从网上 copy 了一个下来了当成了上面的 innerHTML !因为出现了多个 div ,所以现在点日历里面的对象,因为对象重复,所以出错了怎么处理???