<script>
function ch()
{
document.getElementById("ahtm").innerHTML="1.jpg"
}
2、加载改变。注意js代码块一定要写在</a>之后<a name="0" class="STYLE2" id="ahtm" >登</a><script>document.getElementById("ahtm").innerHTML="1.jpg"</script>
<!doctype html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style>
div{
width: 240px
height: 80px
margin: 20px
padding: 20px
border: 1px solid #d5d5d5
}
</style>
<script type="text/javascript">
function changeFont(){
setFont({
id:"test1",
color:"#ff0000",
size: "12px",
family:"微软雅黑"
})
setFont({
id:"test2",
color:"#00ff00",
size: "12px",
family:"楷体",
weight: "normal"
})
setFont({
id:"test3",
color:"#0066ff",
size: "12px",
family:"隶书"
})
}
function setFont(settings){
if(settings && settings.id){
var obj = document.getElementById(settings.id)
obj.style.color= settings.color || '#ffff00'
obj.style.fontSize = settings.size || '36px'
obj.style.fontFamily = settings.family || 'Courier New'
obj.style.fontWeight = settings.weight || 'bolder'
//或者
//document.getElementById("test1").style.font="italic bold 12px arial,serif"
}
}
</script>
</head>
<body>
<div id="test1">这是一个测试1</div>
<div id="test2">这是一个测试2</div>
<div id="test3">这是一个测试3</div>
<button onclick="changeFont()">Change</button>
</body>
</html>