01
2018
01

js实现网页变色效果更换css文件

<!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" />

<link id="a2" rel="stylesheet" type="text/css" href="css1.css" />

<title>无标题文档</title>

<script type="text/javascript">

function anco()

{

var cho=document.getElementById('a2');

cho.href='css1.css';

}

function anco2()

{

var cho=document.getElementById('a2');

cho.href='css2.css';

}

</script>

</head>


<body>

<input type="button" value="红色" onclick="anco()" /><br>

<input type="button" value="蓝色" onclick="anco2()" /><br><br><br><br>

<a onclick="anco()" href="#">红色</a><br><br><br>

<a onclick="anco2()" href="#">蓝色</a>

</body>

</html>


« 上一篇下一篇 »