Asp,Php,Jssdk,mysql,mssql,微信公众号开发,小程序开发-学习笔记 收集日常学习笔记和重点,交流QQ:79657181,手机/微信:18611436777

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>


2018年1月1日 | 发布:anco | 分类:JavaScript | 评论:0