日期:2014-05-16 浏览次数:20406 次
<div id="dome1">dome1</div>
<div id="dome2">dome2</div>
function func(){
var elem = document.getElementById("dome1");
elem.style.color = "red";
var elem = document.getElementById("dome2");
elem.style.color = "blue";
alert(elem.innerHTML);
}
window.onload = func;
var elem = document.getElementById("dome1");// 得到dome1元素
var elem = document.getElementById("dome2");//得到dome2元素
elem.style.color = "red";//dome2元素字体颜色为red
elem.style.color = "blue";//dome2元素字体颜色为blue
alert(elem.innerHTML);//显示dome2内的html