1,要点:先获得标签对象,再通过sytle对其属性进行设置

 

2,主要创新:改变页面的背景颜色:

<!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=utf-8" />
<title>无标题文档</title>
<style type="text/css">
  
 #bodycolor
 {
 font-size:12pt;
 color:red;

 }
 
 .littlered
 {
 color:red;
 font-size:9px;
 }

.bigred
{
  color:red;
  font-size:14px;
}

h2
{
 font-size:16px;
 color:yellow;
 background-color:blue;
}

</style>

<script language="javascript">
function setWhite()
{
  var objEle  = document.all.tags("H2");
   objEle(0).style.color="white";
 
}

function setGreen()
{
  bodycolor.style.color="green"; 
}

function setLarge()
{
 document.all("myH2").style.fontSize="18pt";
 
}

function setSmall()
{
 document.all.bodycolor.style.fontSize="10pt"; 
}
 
 function hideElement()
 {
 if (myH2.style.display == "none")
    myH2.style.display = "";
 else
    myH2.style.display = "none"; 
 
 }
 
 function setBackgroundRed()
 {
 mybody.style.backgroundColor = "red"
 }
 
 function setBackgroundYellow()
 {
 mybody.style.backgroundColor = "yellow"
 }
 function setBackgroundBlue()
 {
 mybody.style.backgroundColor = "blue"
 }
 function setBackgroundWhite()
 {
 mybody.style.backgroundColor = "white"
 }

 

 

 

</script>


</head>

<body >


<h2 />
</form>

</body>
</html>

 

相关文章:

  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2021-12-05
  • 2022-01-06
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-01-12
  • 2021-11-30
  • 2021-12-26
  • 2021-09-01
相关资源
相似解决方案